C++
in a NutshellLast updated: March 28, 2005.
Deletions are shown with red
strike-through style. Insertions are in blue
bold italics. Please send additional errata to cpp @
tempest-sw.com.
Thanks to Paul Bailey, Reed Hedges, James Jennings, Chris Lattner, Michael Kochetkov, Matthias Ragaz, Stefan Stoll, and Ranko Veselinovic for finding and reporting errors.
p. 25, between 4th and 5th items at the top of the page, insert:
unsigned
int
p. 28, line 3 of the typedef example:
typedef double matrix[3][3] matrix;
p. 35, second code block, lines 4, 6, 8:
int & &rr; (insert a space between & and &) int *&* rp = &r; int *&* pr = p;
p. 35, Example 2-12 and the discussion before it are wrong. The
reference to const does not eliminate any copying of the structure
returned from std::div.
p. 42: last line on page: change:
packages in a single source
fileprogram.
p. 45: Example 2-17: insert "ns" in line 5
namespace ns = original; // Alias
p. 59: last line, append:
depth; each subsection covers a single precedence group. The following descriptions apply only to the built-in operators. You can overload many operators for user-defined types (enumerations and classes). See Chapter 5 for more information.
p. 149: 2nd full paragraph:
...object, then the copy constructor is called to copy the
temporary object into .
(The compiler is allowed to optimize away the copy and initialize pz
directly. Most...pz
p. 150: line 3 of first code fragment:
return pz;
p. 251:
insert "const": bool empty() const
insert "iterator": erase(iterator first,
iterator last)
insert "const": bool max_size() const
insert "const": bool size() const
p. 296 (const qualifier) insert in first paragraph:
(line 3) cannot be the target of an assignment, and you cannot
call any of its non-const
member
(line 7) member function, this is a const
pointer to const,
and the member function can be called for
p. 298 (declarator) insert quotes around literal square brackets:
direct-declarator ::= declarator-id
|
direct-declarator (
parm-decl-clause ) [cv-qualifier-seq]
[exception-specification] |
direct-declarator
"["
[constant-expr] "]"
|
( declarator )
direct-abstract-declarator
::=
[direct-abstract-declarator] (
parm-decl-clause ) [cv-qualifier-seq]
[exception-specification] |
[direct-abstract-declarator]
"["
[constant-expr] "]"
|
( abstract-declarator )
p. 330: first paragraph of adjacent_find: move asterisk outside of parentheses:
range [first, last) that are equal
(first version) or in which pred(*iter, *(
is*iter+1))
p. 338: Example 13-1: insert "const" for operator bool()
operator bool() const { return sorted; }p. 356: replace_copy_if: change Iter to InIter
OutIter replace_copy_if(InIter first, InIter last, OutIter result, Predicate pred,
const T& new_value);p. 438: strtoul, end of first paragraph: delete the errant backtick (`):
If the third part is empty, *end
points to the termi-`
p. 531: ignore(), first bullet item, change:
n characters have been read and discarded if n
!= numeric_limits<
intstreamsize>::max()
p. 542 (middle): insert "&"
insert_iterator<Container>& operator++(int)
p. 543 (bottom):
const T* operator->() const
istream_iterator<T,charT,traits,Distance>&
operator++()
istream_iterator<T,charT,traits,Distance>&
operator++(int)
operator>>.
The return value is *this.
istream_iterator<T,charT,traits,Distance>
operator++(int)
operator>>. The return value is a copy of
*this, made prior to reading from the stream..
p. 551, first paragraph after Figure 13-23. Change:
The following member functions of reverse_iterator
refer to adapted as the data member that
stores the base() iterator. The adapted
member is purely a convenience for the
function descriptions and is not necessarily part of any real
implementation of .actually
named reverse_iteratorcurrent, and is a protected data member of
reverse_iterator. (See what happens if you change the
text after the technical editors have done their work.)
p. 551, last paragraph: change:
Saves a copy of the current item
(operator*())*this,
decrements adapted, and returns the saved itemcopy
of *this.
p. 552, second item, change text paragraph:
Saves a copy of the current item
(operator*())*this,
increments adapted, and returns the saved itemcopy
of *this.
p. 672, par. 3, line 3, change max_string to max_size:
length exceeds max_size
throws tring()length_error.
p. 672, last bullet item, change T to Y:
TYou
call