Sams Teach Yourself C++ in 21 Days
52: { 53: for (int i = 0; i < theArray.itsSize; i++) 54: output << “[“ << i << “] “ << theArray[i] &l ...
Templates 677 19 101: { 102: cout << “Enter an offset (0-9) “; 103: cout << “and a value. (-1 to stop): “; 104: cin ...
[5] 50 [6] 60 [7] 70 [8] 80 [9] 90 On line 43, the function template operator<<()is declared to be a friend of the Arraycl ...
Templates 679 19 21: 22: private: 23: int itsWeight; 24: }; 25: 26: // extraction operator for printing animals 27: ostream& ...
70: int itsSize; 71: }; 72: 73: template <class T> 74: ostream& operator<< (ostream& output, const Array< ...
Templates 681 19 119: bool Stop = false; 120: int offset, value; 121: while (Stop == false) 122: { 123: cout << “Enter an ...
***Please use values between 0 and 9.*** Enter an offset (0-9) and a value. (-1 to stop): -1 -1 intArray:... [0] 0 [1] 10 [2] 20 ...
Templates 683 19 Using Specialized Functions .......................................................................... If you u ...
23: }; 24: 25: // extraction operator for printing animals 26: ostream& operator<< 27: (ostream& theStream, const ...
Templates 685 19 72: int itsSize; 73: }; 74: 75: template <class T> 76: Array<T>::Array(int size = DefaultSize): 77: ...
121: 122: 123: void IntFillFunction(Array<int>& theArray); 124: void AnimalFillFunction(Array<Animal>& theAr ...
Templates 687 19 If you are using a Microsoft compiler, uncomment line 67. Based on the C++ standards, this line should not be n ...
15: [0] 0 16: [1] 1 17: [2] 2 18: 19: animal array... 20: [0] 0 21: [1] 10 22: [2] 20 23: 24: Destroyed an animal... 25: Destroy ...
Templates 689 19 Static Members and Templates ...................................................................... A template ...
36: //cout << “animal(int) “; 37: } 38: 39: Animal::Animal(): 40: itsWeight(0) 41: { 42: //cout << “animal() “; 43: ...
Templates 691 19 84: pType = new T[size]; 85: for (int i = 0; i < size; i++) 86: pType[i] = (T)0; 87: itsNumberArrays++; 88: ...
132: Array<int> *pIntArray = new Array<int>; 133: 134: cout << Array<int>::GetNumberArrays() << “ ...
Templates 693 19 The Standard Template Library .......................................................................... As it ...
Understanding Sequence Containers.............................................................. The Standard Template Library se ...
Templates 695 19 elements. The standard vector class provides a constructor that accepts the number of elements as its parameter ...
«
31
32
33
34
35
36
37
38
39
40
»
Free download pdf