Computing Concepts with C++ Essentials

Bug Report Page

First Edition

Second Edition

Book cover

Third Edition

Book errata

* = corrected in the second printing

# = corrected in the third printing

*Page 56
In the main function, the last three lines are indented too far. They should line up with the word double in the first line.
#Page 76 bottom of page
Change the last three 0.01 to 0.05, 0.10 and 0.25 respectively.
Page 77 item 3.
Change "use the format function to achieve special formats" to "use stream manipulators to achieve special formats".
*Page 78 Exercise R2.1
In the last formula, change the "=" under the square root to a "-".
*Page 78 Exercise R2.2
Change dm = m * ((sqrt(1 + v / c) / sqrt(1 - v / c) - 1); to dm = m * (sqrt(1 + v / c) / sqrt(1 - v / c) - 1);
*Page 80 Exercise R2.11
Replace exercises (a) and (b) as follows:
(a) x and "x" are the same if x is an integer.
(b) static_cast<int>(static_cast<double>(x)) is the same as x if x is an integer.
*Page 81 Exercise R2.17
Change
(g) s + n
to
(g) t + s
*Page 118 Exercise R3.7
Change "Your next birthday" to "Lunch time"
*Page 120 Exercise P3.1
Change "(month, day, hour)" into "(hour, minutes)". Change "Then print the number of hours between..." to "Then print the number of minutes between..."
*Page 133 Third line from bottom
change else cout "sqrt(2) squared..." to else cout << "sqrt(2) squared..."
*Page 157
In the table for A or B, the last row should read false false false .
Page 158
Change "Instead, it does the opposite conversion, converting x and y to true or false ." to "Instead, it does the opposite conversion, converting x to true or false." Change "It then converts the and of these two truth values, and finally it tests whether the result is greater than zero." to "If x is not zero, then it tests whether y is greater than 0 and finally computes the and of these two truth values."
Page 159 (2x) and page 160 (1x)
Change country = "USA" to country == "USA".
*Page 164 Exercuse R4.1
Add a semicolon after language = "English".
*Page 166 Exercise R4.10
Change x % 400 == 0 to x % 400 != 0
*Page 169 4th Formula
Add a / between r and the root of q3.
*Page 172 Exercise P4.18
Change "If the transaction was 0, print the balances of both accounts" to "At the end, print the balances of both accounts."
#Page 181 Productivity Hint 5.3
Change “generalized regular expression pattern” to “global regular expression print”
#Page 195
Change future_value(r) to future_value(10000, r, 10)
*Page 208
Change "why we need to set c to 0, not to c / 10" to "why we need to set c to 0, not to c % 10 "
Page 209
Change "and c has changed to c / 100" to "and c has changed to c % 100"
*Page 222 Exercise 5.3
Change
bool is_leap_year(Time t);
string weekday(Time t);
to
bool is_leap_year(year y);
string weekday(int w);
*Page 222 Exercise R5.8
Change print_paycheck(harry, Time(1996, 10, 20, 12, 0, 0, 0)); to print_paycheck(harry);
*Page 223 Exercise R5.9
This exercise is inappropriate since for loops haven't been introduced yet. Also, the global variables should be initialized explicitly. Replace a, b, f and g with the following:
int a = 0;
int b = 0;
int f(int c)
{ int n = 0;
a = c;
if (n < c)
n = a + b;
return n;
}

int g(int c)
{ int n = 0;
int a = c;
if (n < f(c))
n = a + b;
return n;
}

*Page 223 Exercise R5.10
Change "We have seen four kinds of variables in C++: global variables, parameter variables, local variables of a function, and local variables of a block" to "We have seen three kinds of variables in C++: global variables, parameter variables, and local variables".
*Page 225 Exercise R5.20
Change return EXIT 0; to return 0;
*Page 226 Exercise R5.21
Change return EXIT 0; to return 0;
#Page 226 Exercise P5.2
Change “and leaves a and b unchanged” to “and otherwise leaves a and b unchanged”
Page 229 Exercise P5.15
Change
jul = jul + 1 + jalpha - 0.25 * jalpha;
to
long ja = jul + 1 + jalpha - 0.25 * jalpha;;
*Page 232 Exercise P5.22
Change "If n < 0, xn = 1 / xn" to "If n < 0, x n = 1 / x-n"
*Page 233 Exercise P5.25
Change rotate(b, 10 * M_PI / 180); to rotate(b, 10 * PI / 180);.
Page 247 Common Error 6.3
Change '.' to "." (2x)
Page 264 figure on top of page
Remove the box containing the letter e.
*Page 269 buffon.cpp
Change the rangle of the angle in main to
double angle = rand_double(0, 180);
*Page 284 Exercise R6.5
Change the code to
int n;
cin >> n;
double x = 0;
double s;
do
{ s = 1.0 / (1 + n * n);
n++;
x = x + s;
} while (s > 0.01)
*Page 284 Exercise R6.9
Change "There are three kinds of text input: character-oriented, word-oriented, and line-oriented" to "This chapter covered two kinds of text input: word-oriented, and line-oriented"
Page 290 Exercise P6.9
In the second formula for s, change the second sum under the square root,Sxi, to ( Sxi)2
*Page 301 9th line from the bottom
Change "the first idiot user" to "the first user". (As Jo Anna Bradfield points out: "My understanding was that it was said jokingly. Unfortunately the computer science profession has the reputation of being difficult to deal with by, and scornful of, non technical persons. Hence I am concerned that a textbook referring to potential end users as idiots though meant jokingly will subliminally convey a negative attitude toward our clients who in the end pay for these programs we will write.")
*Page 327 Exercise P7.6
Change "There is a reason that the standard C++ library does not provide an arc sine function: it can be computed from the arc tangent function,..." to "The arc sine function can be computed from the arc tangent function,..."
Page 341 and page 345 (product2.cpp)
Change
if (price == 0) return false;
if (b.price == 0) return true;
to
if (b.price == 0) return false;
if (price == 0) return true;
Page 342
Change
if (implicit parameter.price == 0) return false;
if (b.price == 0) return true;
to
if (b.price == 0) return false;
if (implicit parameter.price == 0) return true;
*Page 349 Syntax 8.4
Change "Class_name::Class_name(parameters: " to "Class_name::Class_name(parameters ) :"
Page 351
Change
void Employee::set_salary(double new_salary) const
to
void Employee::set_salary(double new_salary)
(without the const)
*Page 378 Exercise R8.24
Change int h() const to int A::h() const and int k() const to int A::k() const.
*Page 378 Exercise R8.25
Replace x, y, z with a, b, c.
#Page 378 Exercise R8.25
Really replace all x, y, z with a, b, c, i.e. change
A x;
A y(2);
A z = y;
to
A a;
A b(2);
A c = b;
#Page 378 Exercise R8.25
Replace
A d = A(3);
with
A d(3);
*Page 378 Exercise R8.26
Change "that constructs an A object from a string that specifies a number, for example A x("12")." to "that constructs an A object from a floating-point number that is rounded to the nearest integer, for example A x(1.2)."
*Page 379 Exercise P8.1
Change the class to
class Person
{
public:
Person();
Person(string pname, int page);
void get_name() const;
int get_age() const;
private:
string name;
int age; /* 0 if unknown */ };
*Page 383 Exercise P8.17
Change "A message has a recipient, a sender, a time stamp, and a message text." to "A message has a recipient, a sender, and a message text.". On the top of the next page, change "From: Harry Hacker\nTo: Rudolf Reindeer\nTime: ... \n ..." to "From: Harry Hacker\nTo: Rudolf Reindeer\n..."
Page 387
Change "To get some data into staff" to "To get some data into salaries"
Page 388 Figure 3
Replace $35,000 with 35000 (no $, no comma)
Page 391 first paragraph
Change ". . . then it sets that element to e. . . indicates that e is pushed back . . ." to ". . . then it sets that element to s. . . indicates that s is pushed back . . .""
Page 400 find.cpp
Change if (i > 0) to if (i >= 0)
Page 400 last paragraph
Change "either a[i] is the first computer" to "either a[i] is the first value"
#Page 400
Remove the last sentence "Note that we do not ..."
*Page 440 Exercise P9.18
Change "date amount description" to "day amount description ". Change 12/15, 12/16 and 12/1 to 15, 16, and 1. Change "Assume that the interest rate is 5 percent per month." to "Use an interest rate of 1/2 percent per month, and assume the month has 30 days."
*Page 441 Exercise P9.21
Change "an appointment including the starting time, ending time, and a description" to "an appointment including the appointment day, starting time, ending time, and a description". Change the eight output lines to the following four lines:
1996/10/1 17:30 18:30 Dentist
1996/10/2 08:30 10:00 CS1 class
and
1996/10/1 12:30 13:30 Dentist
1996/10/1 13:00 14:00 CS1 class
*Page 443 Exercise P9.25
Change "then you must move to the square to the right and up instead" to "then you must move one square up instead".
*Page 444 Exercise P9.27
The color bands are wrong. If W is the weekday full rate, E the evening rate and N the night and weekend rate, then the matrix is

M T W T F S S
8am-5pm W W W W W N N
5pm-11pm E E E E E N E
11pm-8am N N N N N N N
Page 450 line -2
Change cin >> n to imput_stream >> n
#Page 450
Change input_stream to input_data (3x)
#Page 451
Change input_stream to input_data (1x)
*Page 451
Change fstream output_data; to ofstream output_data;
Page 455
Change stringstream outstr; to ostringstream outstr;
*Page 455
Change string output = outstr.out(); to string output = outstr.str();
*Page 457 readtime.cpp
Change
if (hours < 12)
suffix = "am";
else
suffix = "pm";
hours = hours - 12;
to
if (hours < 12)
suffix = "am";
else
{ suffix = "pm";
hours = hours - 12;
}
*Page 459
Change crypt to caesar (2x)
*Page 460 caesar.cpp
In the encrypt function, change char(...) to static_cast<char>(...) (2x)
Page 462 Figure 2
Change "Alice's private key" to "Bob's public key" and "Alice's public key" to "Bob's private key"
*Page 492 input.cpp
Change
error("Unexpected input " + ch);
to
string message = "Unexpected input ";
error(message + ch);
Page 502 Exercise R11.3
Change "Structure definitions" to "Class definitions".
Page 502 Exercise R11.4
Change "a structure or constant definition" to "a class or constant definition".
Page 504 Exercise P11.4
After the first sentence, add "Read the product data from a file, as in section 10.1."
Page 504 Exercise P11.8
Change "the program of the preceding run" to "the program of the preceding exercise".
*Page 505 Exercise P11.10
Change "Make a class Appointment that stores a description of the appointment, the starting time, and the ending time." to "Make a class Appointment that stores a description of the appointment, the appointment day, the starting time, and the ending time."
Page 541 Exercise P12.10
Change "Hint: Use a stack to keep track of which subarrays have been sorted" to "Keep merging adjacent areas whose size is a power of 2, and pay special attention to the last area in the array."
*Page 542 Exercise P12.15
Change "Make a class Appointment that stores a description of the appointment, the starting time, and the ending time." to "Make a class Appointment that stores a description of the appointment, the appointment day, the starting time, and the ending time."
*Page 544
Change the section heading from "Vector-Based Linked Lists" to "Linked Lists".
*Page 553
Change "cwin << *bubble; /* NO!!! next points to a deleted element */" to "cwin << *bubble; /* NO!!! bubble points to a deleted element */"
*Page 553
Change if (bubble != NULL) cwin << *next; to if (bubble != NULL) cwin << *bubble;
*Page 564 list2.cpp
Remove the declarations class List and class Iterator below the namespace.
Page 562, page 563 and page 566 list2.cpp
Change
void List::erase(Iterator iter)
to
void List::erase(Iterator& iter)
*Page 584 Figures 9 and 10
The labels staff and sales_department should be switched.
*Page 585
In line 3, change void List::copy(const List&; b) to void List::copy(const List& b).
Page 590 Exercise R13.10
Change the code to
Employee harry = Employee("Hacker, Harry", 35000);
Employee boss = harry;
Employee* pharry = new Employee("Hacker, Harry", 35000);
Employee* pboss = pharry;
boss.set_salary(45000);
(*pboss).set_salary(45000);

cout << harry.get_salary() << "\n";
cout << boss.get_salary() << "\n";
cout << pharry->get_salary() << "\n";
cout << pboss->get_salary() << "\n";
*Page 596
Change "namely, the Clock class of Chapter 9" to "namely, the Clock class of Chapter 8".
Page 600 (2x)
Change p.move(0, 2 * radius) to p.move(0, -radius)
Page 623 Exercise R14.3
Change float salary to double salary.
Page 625 Exercise R14.6
Change the definition of D to
class D : public B
{
public:
D();
D(int n);
void print() const;
};
In other words, drop the int n parameter of print and the private data field B b.
Page 628 Exercise P14.9
Remove Weekly. Change occurs_on(int day, int month) to occurs_on(int year, int month, int day).
Page 629 Exercise P14.13
Replace the sentences under the figure ("Users can save...Follow the hints of Exercise P14.11") with "Hint: Supply virtual functions make_shape(Point p) that return a new shape of default size anchored at the point p.
Page 654
Change string message = "Hello, \"World\ "\n"; to string message = "Hello, \"World\"\n"; (i.e. remove the space before thr second backslash).

CCC Code bugs

The following bug is fixed in the current code release .

ccc_shap.cpp
The Message::get_text function was called get_message.

Thanks to Paulo Alessandro, Jeffrey Beall, Jo Anna Bradfield, Brian Day, Toby Donaldson, Gary Frankenbery, Peter Gacs, Paul Haines, David Hallett, Jiri Herrmann, Brian C. Ladd, Gretchen Lynn, Roger Mitton, Ho-Kuen Ng, Jen Pedler, Peter Stone, Steve Weissman and a number of anonymous contributors for their help!