
Answer:
Answer: Answers to the odd-numbered
exercises are available for all readers. If you are an instructor,
please visit http://www.wiley.com/college/horstmann
and select "Instructor Resources". You will need to fill out a form and
obtain a password to see the solutions to all exercises.
Answer: The
following compilers should work:
Answer: Your compiler
(Microsoft Visual C++ 6) does not conform to the C++ standard. A remedy is
to add a line
namespace std {}
above the using namespace std; directive.
Answer: Your compiler (Microsoft Visual
C++ 6) does not conform to the C++ standard. A remedy is to rename the index
variable in the second loop.
Answer: Your compiler
(Microsoft Visual C++ 6 or g++ 2.9x) does not conform to the C++ standard. A
remedy is to add the line
double max(double x, double y) { if (x > y) return x; else return y; }
Answer: Your compiler (g++
2.9x) does not conform to the C++ standard. A remedy is to change
#include <sstream>
. . .
istringstream instr(s);
. . .
ostringstream outstr;
. . .
s = outstr.str();
to
#include <strstream>
. . .
istrstream instr(s.c_str())
. . .
ostrstream outstr;
. . .
s = string(outstr.str());
Answer: Your compiler (g++ 2.9x) does not conform to the C++ standard. A remedy is to replace fixed with setiosflags(ios::fixed)
Answer: It is not a part of the ISO standard, and some compilers don't define it. If you find it implausible that the standard doesn't define it, you can purchase an official copy or check out an inofficial working draft.
Answer: (1) STL uses doubly-linked lists. (2) It is actually easier to implement insertion and deletion in a doubly-linked list.
Answer: This is a book about computing concepts, not about C++. Strings are a concept. ANSI C++ supports two implementations of strings: the string class and char* pointers. There is no doubt that many C++ programmers will need to learn both implementations, but I do not believe they should learn all details of both of them in their first programming course. The string class is safe and convenient. Students master it quickly and can move on to learning more computing concepts.
Answer: The <iostream> header and the std namespace were introduced in 1996 and approved in the international standard in 1998. If your compiler does not support these constructs, you will need to upgrade your compiler. g++, Borland C++ 5.5 and Microsoft Visual C++ 6 are reasonably standard compliant.
Answer: Here is a list of currently supported platforms.
Answer: The CCC graphics library has been purposefully kept simple so that students don't fritter away endless time with color and fancy fonts. Use wxWidgets if you want fancier graphics
Answer: There are many different schemes to name accessors, mutators and data fields. The C++ library uses overloaded pairsseconds() and seconds(int) for accessors and mutators, which I think is a bit too confusing. I felt the get/set terminology makes it really clear that the accessor is a function call. And, of course, that is the convention used in Java.
Answer: The standard C++ library uses no uppercase letters at all, and it uses underscores to make names more readable (bad_cast, push_back). There is nothing wrong with mixed case (getSeconds, readInt); I just wanted to be consistent.