Errata and Clarifications of Discovering Modern C++ (1st edition)

  • Page xxiii, first paragraph: For Mulanasky read Mulansky. Sorry, Mario! (Fixed in second printing.)
  • Page xxiii, last paragraph: My son's name is Daniel, not Daniely. (Thanks to my wife, catching this at first glance! Fixed in second printing.)
  • Page 4, second line from bottom: Surplus ";" after "long double". (Thanks to Igor Krasikov for this finding and several others. Fixed in second printing.)
  • Page 5, §1.2.1: For "const char   cc 'a';" read "const char   cc= 'a';". (Thanks to Adil Billa, 2015-12-30. Fixed in second printing.)
  • Page 12, line 11: For "\%" read "%". (Fixed in second printing.)
  • Page 14, line 5 from bottom: For x < y read x <= y. (Thanks to Bai Du.)
  • Page 26, formula and first code snippet: all occurences of "i" should be replaced by "n". For "i=0" in the formula read "n=0". For consistency, the loop variable in the code should better be "n" as well: "for (unsigned long n= 1; n <= 10; ++n)" as well as "fac*= n;". (Thanks to Olivia Basegio.)
  • Page 27, line 16: less indentation for "x+=dx;". (Fixed in second printing.)
  • Page 32, line 1: For with "int and double parameters" read "with int and float parameters". (Thanks to Kilian Henneberger.)
  • Page 33, line 17 from bottom: For "argc[0]" read "argv[0]". (Fixed in second printing.)
  • Page 41, line 12 from bottom: For "myfile" read "square_file". (Fixed in second printing.)
  • Page 41, line 9 from bottom: There should be a << between "^2=" and i*i. (Quotes are actually part of the code in this case. Fixed in second printing.)
  • Page 42, line 9: the same. (Fixed in second printing.)
  • Page 46, line 10 from bottom: For "o1" read "o2". (Fixed in second printing.)
  • Page 55, first code block, last line: Should be std::cout << "i = " << i << '\n'; as printing i instead of j makes more sense to demostrate the interference.
  • Page 60, line 10 from bottom: Replace "/DNO_MIN_MAX" with "/DNOMINMAX".
  • Page 63, § For "#enif" read "#endif", three times. (Thanks to Nishant Mehta, 2016-01-05. Fixed in second printing.)
  • Page 73, line 3 from bottom: For "Unfortunately, matrix is not" read "Unfortunately, matrix_type is not". 
  • Page 74, second paragraph: Please ignore the formatting of "matrix", it is just a word not actual code here.
  • Page 75, second code block, line 4: There should be no semicolon, i.e.: "   z4= 4,   // short for z4(4.0, 0.0)". (Thanks to Kilian Henneberger).
  • Page 76, code block: After the constructor of z2 should be a comma, not a semicolon, i.e. "z2(z1);" should be "z2(z1),". (Thanks to Kilian Henneberger).
  • Page 83, code block: Replace "self&" with "vector&" as return type of operator= (however, I assumed self to be a type definition in the omitted part).
  • Page 124, line 11: A bracket got lost in the formatting of "new Tmy_size]", it should be "new T[my_size]".
  • Page 126, second code block, line 2: The variable "di" should be "ad".
  • Page 130, line 8: "operator*operator*" should be "operator*", obviously. (Thanks to Kilian Henneberger).
  • Page 130, line10: The pre-increment operator better returns a reference of the iterator, i.e.: "list_iterator<T>& operator++()". (Thanks to Kilian Henneberger).
  • Page 132, line 12: and 16, in comments "of f" should be "of g". Line 20 has the same typo (f -> g).
  • Page 137, line 3: For "Listing 3.3.1" read "Listing 3-1".
  • Page 137, line 10 from bottom: The expression  *(my_size+7)/8* should be [(my_size+7)/8].
  • Page 138, seconde code block: double code line, please ignore one.
  • Page 149, § 3.8.2, first paragraph: For "We can can" read "We can" and for "holds the the function" read "holds the function". (Thanks to kw0lf).
  • Page 157, second code block: The line "struct lambda_f" should not be there and the operator be const, i.e. the signature should be "double operator()(double x) const". (Thanks to Kilian Henneberger).
  • Page 163, exercise 3.11.10, first bullet point: "exp(-3x)" should be "exp(3x)" to be consistent with the code snippet. (Thanks to Cornelius Steinhardt).
  • Page 169, line 6: Instead of "Where our first snippet used const_iterator" it would be more correct to start the sentence with "Whereas the considered example could use a const_iterator". (Thanks to Kilian Henneberger for pointing out the inconsistency in the text).
  • Page 178: The string "The value of pi is " should be "The circle ’s circumference pi is" to match the output below.
  • Page 196, normal and log-normal distributions: The denominators should not be √2π but √(2π), i.e. the square root's upper bar should be prolongated over π.
  • Page 196, student distribution: p(x|m) should be p(x|n).
  • Page 198, code block: Semicolon missing after last statement.
  • Page 200, line 14: Instead of "the approximated result of √x should be in the ε-environment of x" it is more correct that "the squared approximated result ...".
  • Page 200: reference to program "c++11/is_pod_test.cpp" should not be there, the subsequent code is in "c++11/type_traits_example.cpp" (Thanks to Kilian Henneberger).
  • Page 203, line 9: The "i" in "2.0+9.0i" is a user-defined literal which I planned to introduce in the book but finally didn't. The feature is introduced in C++11, and "i" was defined as  "complex<double>(0.,1.)" in C++14.
  • Page 206, line 2: For "decayed to pointer pointers" read "decayed to function pointers".
  • Page 216, caption Figure 4-9: For "Julia" read "Julia set". (Fixed in second printing.)
  • Page 225, line 5: For "Section 5.2.5" read "Appendix A.9.2".
  • Page 255, line 5 from bottom: The template arguments should not be "<Target , Source , [*N-1>" but "<Target , Source , N-1>". See also remark below.
  • Page 290, lines 4-5: For "access members of the derived class" read "access the hidden members of the base class".
  • Page 290, line 17, comment: "pp{tom}" should be "pp{&tom}".
  • Page 292, code block: The class person needs a virtual destructor "virtual ~person() {}" for proper handling of polymorphic pointers and references.
  • Page 294, line 5 from bottom: For "person::all_info() is not lately bound to person::all_info()" read "pr.all_info() is not lately bound to student::all_info()".
  • Page 305, code block: The method "my_info()" was not introduced before. It provides information stored in the class' members but not those in the base class' members.
  • Page 313, last row of table 6.1: For "RTI check" read "RTTI check".
  • Page 315, line 7 from bottom: For "T{u} Tu" read "T{u} or T(u)".
  • Page 318, line 3-4: For "is an up-casted this pointer to point " read "is an up-casted this pointer to point* ".
  • Page 325, fig. 7.2a: For "cs,s-1" read "as,s-1". 
  • Page 325, Listing 7-1, line 8: For "for(int i= 0; i<x.size(),++i)" read  "for(int i= 0; i<x.size(); ++i)" (semicolon instead of comma).
  • Page 331, line 7: For "rk_stype rk4;" read "rk4_type rk4;".
  • Page 361, first code: For "double scr1*}," read "double scr1,. (Thanks to Kilian Henneberger).
  • Page 365, four code snippets: The commands to print out the intermediate results were too large for the book pages and the lines were broken into two shorter lines. Unfortunately, not in a C++-conform manner. Instead of:
    cout << "inverse(U) [permuted] is:\n" << UI << "UI * U
                                                          is:\n" << Matrix(UI * U);

    It should be:
    cout << "inverse(U) [permuted] is:\n" << UI
             << "UI * U is:\n" << Matrix(UI * U);

    Likewise for the following snippets.
  • Page 370, last code block: "trans(T)" should be "trans(A)". (Thanks to Kilian Henneberger).
  • Page 373, line 2 from bottom: The pointer should not have type "unique_ptr<double>" but "unique_ptr<double[]>". (Thanks to Kilian Henneberger).
  • Page 374, third code block, line 3: The last test should not be "c <= ncols" but "c < ncols". (Thanks to Kilian Henneberger).
  • Page 392, line 12: There should be only one "=" not two.
  • Page 393, last text line: For "we see see the" read "we see the".
  • On page 398, line 4 from bottom: Better than "vector<T>& operator|=(vector<T>& v, int mask);" would be a template parameter "vector<T>& operator|=(vector<T>& v, const T& mask);".
  • Page 400, lines 10 and 11 from bottom: are the same. Please ignore one.
  • Page 414, Dereference item: For "* lvalue" read "* expr".

Feel free to report an error as comment. They will be incorporated into the errata occasionally (or counter-commented in case I'm not conviced). As the page is already long enough, processed comments are deleted.

Several formatting issues reported to me may not be listed here but will be considered for later printings. For consistency's sake, all loop indices should be incremented with the prefix operator but few suffix increments and decrements still exist which are not to list here.

"[*" is LaTeX escape sequence I defined for highlighting parts of a code. Unfortunately, it appeared several times in the listings after the LaTeX transformation for the print. Many of them were caught before printing but not all. Likewise, code identation was also affected by this transformation and most badly idented listings were corrected in the last minute.

I am deeply in depth to Igor Krasikov who reported by far the most issues and who is also translating the book to Russian.

Back to the book's main page.

© 2019 SimuNova UG