C++ Book page | Student File Download Area

Errata - Last update: 9/21/97

Page

Description

20 Insert "the" near the bottom of the page: "Assuming that the user does not type the first...
26 The declaration of the SetX function should be:
void SetX( int xval );
36 Delete the following statement from the Point constructor at the top of the page:

return *this;

48 In the sample data listing, insert a new line after the line beginning with "962":

4 number of courses

89 In the listing of the operator << function, remove the semicolon at the end of the following line:

ostream & operator <<(ostream & os, const Point & p );

104 In Exercise 3, Validating the Input Data, use the following test data to test your handling of input stream errors. The first will be an invalid employee ID, the second will be an invalid pay rate, and the third will be an invalid number of hours worked:

a10000 Gonzalez 12.50 50
30000 Davis g15.85 52
50000 Rostropovitch 45.2 z56.2

133 At the beginning of main in the code example in the middle of the page, insert the following line:

srand(); // seed the random number generator

This will ensure that a different set of robot groupings is created each time the program runs.

139 Suggestion: In Exercise 3, Student Record Example, the program is easier to write if you use spaces to delimit the fields in the input data file. Also, use underscores to eliminate the spaces inside the course names. For example:

H 10000 Jones Sam
C CGS_1060 4
C ENC_1101 3
C MAT_1033 3
(etc.)

140 In Exercise 5, Table Lookup, Multiple Results, the MultiSearch function does not have to allocate its own array of results. Instead, pass a pointer to an empty results array from the main program.
141 View supplemental notes for the EncryptedFile Class exercise.
141 In the Date Class exercise, always use 4-digit year numbers.
144 In Exercise 4.8.3 #1 (WindArray Class), the second paragraph should begin with the following sentence: "Calculate the average wind velocity, using a 30-minute moving average."
145 Replacement for Page 145, Robot Wars programming exercises.
182 In the Point and Point3D class definitions, the SetX, SetY, and SetZ functions should be declared as follows:

void SetX( int xv );
void SetY( int yv );
void SetZ( int zv );

187 In the Point class definition, the SetZ function should be declared as follows:

void SetZ( int zv );

233 The first line of the code example near the top of the page should contain the following line:

#include <stdlib.h> // used by exit()

314 In the code example at the bottom of the page, delete the following lines from the operator = function:
if( *this == s )
  return *this;
323 In the code example at the bottom of the page, MaxCourses should be spelled MaxCourse.
358 The four Array template declarations at the bottom of the page should contain array size arguments:

Array<int> X(50);
Array<float> Y(50);
Array<FString> Z(50);
Array<Point> W(50);

374 The comments under the FirstKeyOf function in Exercise 2, Dictionary Value Search should be as follows:

// Find the first item that matches the value
// contained in v. Set the current position to the
// position of the item. Return 1 if successful,
// 0 if not.