In Review 801
379: catch (EmptyList)
380: {
381: cout << “The list is empty!” << endl;
382: return 1;
383: }
384: catch (BoundsError)
385: {
386: cout << “Tried to read beyond the end of the list!” << endl;
387: return 1;
388: }
389: return 0;
390: }
(0)Quit (1)Car (2)Plane: 1
New PartNumber?: 2837
Model Year? 90
(0)Quit (1)Car (2)Plane: 2
New PartNumber?: 378
Engine Number?: 4938
(0)Quit (1)Car (2)Plane: 1
New PartNumber?: 4499
Model Year? 94
(0)Quit (1)Car (2)Plane: 1
New PartNumber?: 3000
Model Year? 93
(0)Quit (1)Car (2)Plane: 0
Part Number: 378
Engine No. 4938
Part Number: 2837
Model Year: 90
Part Number: 3000
Model Year: 93
Part Number 4499
Model Year: 94
The Week 3 in Review listing modifies the program provided in Week 2 to add
templates,ostreamprocessing, and exception handling. The output is identical.
On lines 36–40, a number of exception classes are declared. In the somewhat primitive
exception handling provided by this program, no data or methods are required of these
DAY 20
OUTPUT
ANALYSIS
LISTINGR3.1 continued
28 0672327112_w3_wir.qxd 11/19/04 12:30 PM Page 801