Sams Teach Yourself C++ in 21 Days
496 Week 2 159: delete pHead; 160: } 161: 162: Part* PartsList::GetFirst() const 163: { 164: if (pHead) 165: return pHead->Ge ...
In Review 497 193: if (pNode->GetPart()->GetPartNumber() == PartNumber) 194: break; 195: } 196: if (pNode == NULL) 197: re ...
498 Week 2 237: for (;;) 238: { 239: // if there is no next, append this new one 240: if (!pCurrent->GetNext()) 241: { 242: p ...
In Review 499 284: pPart = new CarPart(value,PartNumber); 285: } 286: else 287: { 288: cout << “Engine Number?: “; 289: ci ...
500 Week 2 Class Partis declared on lines 27–37, and consists of a part number and some accessors. Presumably, this class could ...
In Review 501 On lines 212–258, the Insert()method takes a pointer to a Part, creates a PartNodefor it, and adds the Partto the ...
502 Week 2 On line 232, the new node is set to point to the node currently pointed to by pHead. Note that this does not point th ...
At a Glance You have finished the second week of learning C++. By now, you should feel comfortable with some of the more advance ...
20 0672327112_w3_aag.qxd 11/19/04 12:28 PM Page 504 ...
DAY 15 WEEK 3 Special Classes and Functions C++ offers several ways to limit the scope and impact of variables and pointers. So ...
Sharing Data Among Objects of the Same Type: Static Member Data .............. Until now, you have probably thought of the data ...
Special Classes and Functions 507 22: const int MaxCats = 5; int i;^15 23: Cat *CatHouse[MaxCats]; 24: 25: for (i = 0; i < Ma ...
On line 8, the constructor for Catincrements the static member variable. The destructor decrements it on line 9. Thus, at any mo ...
Special Classes and Functions 509 22: int main()^15 23: { 24: const int MaxCats = 5; int i; 25: Cat *CatHouse[MaxCats]; 26: 27: ...
The alternative to making this member variable public is to make it private. If you do, you can access it through a member funct ...
Special Classes and Functions 511 15 There are 5 cats left! Deleting the one that is 2 years old There are 4 cats left! Deleting ...
8: virtual ~Cat() { HowManyCats--; } 9: virtual int GetAge() { return itsAge; } 10: virtual void SetAge(int age) { itsAge = age; ...
Special Classes and Functions 513 15 The static member variable HowManyCatsis declared to have private access on line 14 of the ...
Pointers to Functions .......................................................................................... Just as an arra ...
Special Classes and Functions 515 7: void Swap (int&, int &);^15 8: void GetVals(int&, int&); 9: void PrintVals( ...
«
22
23
24
25
26
27
28
29
30
31
»
Free download pdf