Learn To Program With C++
McGraw Hill/Osborne
0072-225-351
Errata and Source Code
Updated January 24, 2009
Every author
endeavors for perfection. My apologies for the typos that have slipped through.
We'll do our best to have these corrected for the next printing. What's a
'gotcha'?
It's not an errata--but it is
something that, for whatever reason, people are missing.
Gotcha #1--the Command
Prompt (Page 44)
A number of people reports problems
when they open up a command window that they are not seeing the same thing
displayed in the book. That's perfectly fine.
What you see, in the title bar of
the Command Window, is the 'Current folder' or 'Current directory' that the
Command Window places you in. Regardless of what it happens to be, you can
still 'navigate' to the correct folder by using the CD command illustrated on
page 44, which a bunch of people are missing. Using the CD command, you can get
to the location of your C++ Source file--no matter where it is. And, provided
you have properly installed your compiler, you can then execute your program
from anywhere.
General problem with
cin.getline(response,256);
I'm receiving reports that this
line of code
cin.getline(response,256);
is failing to permit the user to enter a response
when used with certain compilers such as
If so, replace it with this one
cin >>
response;
and you'll be OK.
Chapter 1
- Page 11, 4th paragraph: "...will cause him to think
of something else he wants to the program to do." Extra
"to" in there.
Chapter 2
None that we know of
Chapter 3
- Page 109, under the Increment
Operator. "In other programming language, this code..." should
be "In other programming languages, this code.."
- Page 127, middle of the page. "...and your
right-hand expression is just the number 99." should be "...and
your right-hand expression is just the number 88."
Chapter 4
- Page 151, last line of code in Step 1. This should
contain a 'return 0' statement.
- Page 172, code in Exercise 4-7. This line
const
float MATH_MIDTERM_PERCENTAGE =.5F;
should be
const float
MATH_MIDTERM_PERCENTAGE =.50;
- Page 173, Code. Although it works, the single Pipe
Operator | should be ||. The | Operator is actually a Bitwise Inclusive Or
Operator.
- Page 174, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 175, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 176, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 180, Code. Although it works, the single Pipe
Operator | should be ||. The | Operator is actually a Bitwise Inclusive Or
Operator.
- Page 182, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 183, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 184, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
Chapter 5
- Page 221, Code. Although it works, the single Pipe
Operator | should be ||. The | Operator is actually a Bitwise Inclusive Or
Operator.
- Page 222, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 223, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 224, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 225, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
Chapter 6
- Page 259, Code. Although it works, the single Pipe
Operator | should be ||. The | Operator is actually a Bitwise Inclusive Or
Operator.
- Page 265, Code. Although it works, the single Pipe
Operator | should be ||. The | Operator is actually a Bitwise Inclusive Or
Operator.
- Page 268---the variables balance, newBalance, and
adjustment have been declared on Page 264 without the static keyword---it
should not appear here.
- Page 275, Code. Although it works, the single Pipe
Operator | should be ||. The | Operator is actually a Bitwise Inclusive Or
Operator.
- Page 276, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 277, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 281, Code. Although it works, the single Pipe
Operator | should be ||. The | Operator is actually a Bitwise Inclusive Or
Operator.
Chapter 7
- Page 293. If you attempt to compile Example7_1.cpp, be
sure to code the Banner.cpp program on Page 289.
- Page 294. "I though the compile failed?" should
be "I thought the compile failed?"
- Page 296, 8 lines from the bottom. "So can we can retrieve
the value" should be "So can we retrieve the value"
- Page 326, Code. Although it works, the single Pipe Operator
| should be ||. The | Operator is actually a Bitwise Inclusive Or Operator.
- Page 331, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 334, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 336, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
Chapter 8
- Page 374, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 377, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
- Page 380, Code. Although it works, the single & should
be &&. The & Operator is actually a Bitwise And Operator.
Chapter 9
- Page
395. "Finally, we also have the public Calculate()
Method, which outputs the employee's information to the C++ console "
This should read "Finally, we also have the public Display()
Method, which outputs the employee's information to the C++ console
- Page 400, 5th line of code. The SalariedEmployee class
erroneously is deriving from EmployeeBase. EmployeeBase isn't introduced
until Page 411. The code should read...
class SalariedEmployee: public Employee
- Page 400. The code in SalariedEmployee should not yet
have a SalariedEmployee Constructor. Please remove it.
- Page 408. Dave, in his discussion, points out that the
Constructor for Employee is executing. Because the book erroneously
included a SalariedEmployee Constructor on Page 400, you may have noticed
that run ALSO. Notice that we then added the SalariedEmployeeConstructor
on Page 408.
Chapter 10
- Page 448. This section is confusing because I imply that
the number contained within brackets is the 'upper floor' of the array.
The number contained within brackets is the total number of elements
(size) of the array.
- Page 448. To be consistent with the followon discussion,
this line of code...
int
grades[6];
should read
int
grades[5]
- Page 448. "...was actually a string array containing
257 elements..." should read "...was actually a string array
containing 256 elements..."
- Page 482, Discussion. Last sentence of the first
paragraph reads "We declared grades as an array of the double data
type..." We actually declared it as a float data type.
Chapter 11
- Page 510, last 3 lines. I say you can reference an array
name to display the address of an array, but then I use the pointer name
in the example. Change the code to read like this…
Cout << “The value of pGrades is “ << Grades <<
endl;
Chapter 12
None that we know of