Sams Teach Yourself C++ in 21 Days
188: if (pNode->itsPart->GetPartNumber() == PartNumber) 189: break; 190: } 191: if (pNode == NULL) 192: return NULL; 193: ...
Advanced Inheritance 577 16 238: return; 239: } 240: 241: // if this goes after this one and before the next 242: // then insert ...
290: Find(offset,PartNumber); 291: return offset; 292: } 293: 294: Part * PartsCatalog::Get(int PartNumber) 295: { 296: int offs ...
Advanced Inheritance 579 16 (0)Quit (1)Car (2)Plane: 1 New PartNumber?: 1234 Model Year?: 94 (0)Quit (1)Car (2)Plane: 1 New Part ...
Friend Functions .................................................................................................. You just lea ...
Advanced Inheritance 581 16 What you could not do, however, was create a C-style string (a character string) and add to it using ...
29: String (int); // private constructor 30: char * itsString; 31: unsigned short itsLen; 32: }; 33: 34: // default constructor ...
Advanced Inheritance 583 16 79: } 80: 81: // destructor, frees allocated memory 82: String::~String () 83: { 84: delete [] itsSt ...
131: String temp(totalLen); 132: int i, j; 133: for (i = 0; i<itsLen; i++) 134: temp[i] = itsString[i]; 135: for (j = 0, i = ...
Advanced Inheritance 585 16 s1: String One s2: String Two c1: C-String One s3: String One String Two s4: String One C-String One ...
What you would like to do is write this: cout << theString; To accomplish this, you must override operator<<(). Day ...
Advanced Inheritance 587 16 41: // ConstructorCount++; 42: } 43: 44: // private (helper) constructor, used only by 45: // class ...
93: if (this == &rhs) 94: return *this; 95: delete [] itsString; 96: itsLen=rhs.GetLen(); 97: itsString = new char[itsLen+1] ...
Advanced Inheritance 589 16 143: { 144: unsigned short rhsLen = rhs.GetLen(); 145: unsigned short totalLen = itsLen + rhsLen; 14 ...
the aggregated object. Aggregation is simpler to use than inheritance, and should be used when possible. You also saw how to dec ...
Advanced Inheritance 591 16 Workshop ........................................................................................... ...
15: }; 16: 17: void setValue(Animal& theAnimal, int theWeight) 18: { 19: friend class Animal; 20: theAnimal.itsWeight = theW ...
DAY 17 WEEK 3 Working with Streams Until now, you’ve been using coutto write to the screen and cinto read from the keyboard, wit ...
them and run them on a Sun Workstation, or you can take code created using a Windows C++ compiler and recompile and run it on Li ...
Working with Streams 595 17 problem, streams provide “buffering.” When buffering is used, data is written into the stream, but i ...
«
26
27
28
29
30
31
32
33
34
35
»
Free download pdf