Changes Made from the Second Printing to the Third

Chapter 1

Page

Line

Change

To

vii

Last paragraph

Replace

 Standard C++

At the time of writing this text, no C++ standard had been adopted.   Many of the changes from the first edition of this text were the result of language changes proposed in the various draft standards released for public review.   For example, our presentation of types in Chapter 2 includes the bool type; in Chapter 4, we use the standard string class (instead of constructing a new Strings class as in the first edition); we present vector<T> and list<T> from the Standard Template Library. In November, 1997, a final draft was approved unanimously as an ISO/ANSI standard for C++.  This latest printing of the text now incorporates the changes from this final document such as the use of new standard library names, the standard namespace std, modified functions for several standard classes such as string, and stringstreams. The text now conforms fully to the ISO/ANSI C++ standard.

xx 

9B

fstream Operations

Stream Features

 

7B

499

497 

 

6B

500

499

 

5B

502

 501

 

5B

(Insert new line)

 String Streams   503

xxi

16T

An Object-Oriented Approach  540

An OOP Approach — valarrays   538

32

6, 7 of Fig. 1.2

iostream.h
Insert after line 7:

iostream
using namespace std;

 

5B of Fig. 1.2

Delete return 0;

 

33

Para. 2

Replace

The two lines that begin with #include are compiler directives that instruct the compiler to add to the program items in a library iostream needed to do input and output and items in a library string needed to process character strings.  (The items are listed in comments following //.)   We want these to be the standard libraries in the namespace named std.  (See Footnote 2.)  The next line informs the compiler of this.  Without it we would have to qualify each item such as cout from these libraries with the prefix std::; for example, 

  std::cout << "Please enter your first name: ";

 

 

Add

Returning 0 usually indicates normal termination.  Some programmers (and some compilers) may, in fact, use a return statement return 0; as the last statement in the program.  Returning a nonzero value indicates abnormal termination.

 

Last para. 

Delete

 

38

Last para.

Replace

This sequence of instructions is called a pseudocode algorithm, because although it is not written in a programming language, it is somewhat similar to a program's code. This algorithm becomes our blueprint for the next stage of the process.

39

First para.

Replace

Once we have an algorithm for our problem, we must translate it into a high level language like C++. Figure 1.3 shows the program that results.2

 

7-8 of Fig. 1.3

iostream.h
math.h

Insert after line 8:

iostream
cmath
using namespace std;

 

Footnote

Add

|2 New names for standard libraries along with namespaces, which make it possible to group together things that logically belong together, are recent additions to C++ (see § 7.5). With older compilers it may be necessary to use the older library names — e.g., iostream.h instead of iostream and math.h instead of cmath — and remove the using namespace std; line.

40-41

Footnote references

2, 3, 4

3, 4, 5

42

7-8 of Fig. 1.4

iostream.h
math.h
Insert after line 8:

iostream
cmath
using namespace std;

43

Last line before §1.3

const PI

const double PI

45

6 of Fig. 1.5

iostream.h
Insert after this line:

iostream
using namespace std;

47

5-6 of Fig. 1.6

iostream.h
iomanip.h
Insert after line 6:

iostream
iomanip
using namespace std;

 

Footnote

Add

Also, <iomanip.h> may be needed instead of <iomanip> — see Footnote 1.

49

1

iostream.h
Insert after this line:

iostream
using namespace std;

 

10

Delete return 0;

 

 

Changes in Chapter 2