Sams Teach Yourself C++ in 21 Days

(singke) #1
Advanced Inheritance 569

16


297: return (Find(offset, PartNumber));
298:
299: }
300:
301: int main()
302: {
303: PartsCatalog pc;
304: Part * pPart = 0;
305: int PartNumber;
306: int value;
307: int choice = 99;
308:
309: while (choice != 0)
310: {
311: cout << “(0)Quit (1)Car (2)Plane: “;
312: cin >> choice;
313:
314: if (choice != 0)
315: {
316: cout << “New PartNumber?: “;
317: cin >> PartNumber;
318:
319: if (choice == 1)
320: {
321: cout << “Model Year?: “;
322: cin >> value;
323: pPart = new CarPart(value,PartNumber);
324: }
325: else
326: {
327: cout << “Engine Number?: “;
328: cin >> value;
329: pPart = new AirPlanePart(value,PartNumber);
330: }
331: pc.Insert(pPart);
332: }
333: }
334: pc.ShowAll();
335: return 0;
336: }

(0)Quit (1)Car (2)Plane: 1
New PartNumber?: 1234
Model Year?: 94
(0)Quit (1)Car (2)Plane: 1
New PartNumber?: 4434
Model Year?: 93
(0)Quit (1)Car (2)Plane: 1
New PartNumber?: 1234
Model Year?: 94

OUTPUT


LISTING16.6 continued

Free download pdf