API Design for C++

This page contains information about updates or errors that have been received for the book API Design for C++. If you wish to report a suspected error then please refer to the Author page for contact details.

2nd Edition

The second edition involved an end-to-end rewrite of the book along with a full copyediting process. This fixed several issues in the First Edition text, in addition to the following errata that were submitted by Yilmaz Arslanoglu and Fernando Rozenblit after the final printing of the First Edition.

  • Page 76: add free(ptr->mName); before free(ptr); in the code sample
  • Page 220: replace “the mName member variable” with “the two member variables”

1st Edition - Third Printing

The third printing of the first edition encompasses all of the issues listed below for the first and second printings and includes the following additional corrections. Many thanks to Roger Orr, Chris Bond, Philip Koshy, Andrea Bigagli, Jiang Zhiqiang, William Sommerwerck, and Mark Jones for contributing to this list.

  • Page 24: replace “multiple People objects” with “multiple Person objects”.
  • Page 24: replace “Telephone Number: Describes a single address” with “Telephone Number: Describes a single telephone number.”
  • Page 24, Fig 2.2: add AddAddress() and AddTelephoneNumber() to the Person object.
  • Page 61: insert “(or std::bind in C++)” after boost::bind
  • Page 75: for the .h code: change AutoTimerCreate() to AutoTimerCreate(const char *name)
  • Page 86: IRenderer code example should declare its pure virtual function as public.
  • Page 87: RayTracer code example should declare its pure virtual function as public.
  • Page 90: Remove: “In fact, you could even enforce this convention by adding the Create() call as another pure virtual method on the IRenderer abstract base class.”
  • Page 143: Change “The same is true for all symbols that begin with two underscores followed by a capital letter.” to: “The same is true for all symbols that contain a double underscore or begin with an underscore followed by an uppercase letter.”
  • Page 171: in source code, change float param_inc; to float param_increment;
  • Page 188: In “Consequently, using explicit instantiation can also help increase build times.” reword to say “reduce build times”.
  • Page 216: added note about redundant #include guards breaking encapsulation.
  • Page 223: added “and in C++11 these can be found in the cstdint header.”
  • Page 226: Replace “negatively impact” with “reduce”.
  • Page 362: Change “Firefly” to “Firefox”.
  • Page 383: Remove “(BaseNode::Accept() will also have to be modified so that it is no longer a pure virtual method)”

1st Edition - Second Printing

The second printing of the first edition became available in early 2012. All of the issues listed below for the first printing were corrected in the second printing. This section details additional errata for the second printing. Many thanks to Çağdaş Çalık and Markus Geimer for contributing to this list.

  • Page 24: Figure 2.2: change “GetFormattedString” to “GetFormattedNumber” to be consistent with the text
  • Page 31: replace “<stdio.h>” with “<cstddef>” for size_t declaration
  • Page 81: prefer declaring Mutex as a file-scope static.
  • Page 106: change “Cunninghman” to “Cunningham”
  • Page 114: remove “a” from “Each use case should be a written in plain English”
  • Page 152: change “file scope level of your .cpp files” to “file scope level of your .c files”
  • Page 152: remove “libz” from the Image Libraries bullet
  • Page 178: remove “#include <iostream>” as it’s unnecessary
  • Page 192: replace “free operator” with “free function operator” to reduce ambiguity in last paragraph
  • Page 194: replace “<iostream>” with “<iosfwd>”
  • Page 213: const &B obj -> const B& obj (2 instances)
  • Page 214: mention “<iosfwd>” before 2nd tip when talking about STL forward declarations
  • Page 220: “only the assignment operator is invoked” becomes “only the copy constructor is invoked”
  • Page 224: reorder data members from largest to smallest (as suggested by AMD’s Software Optimization Guide)
  • Page 240: under ThreadSpotter: change “Acumem” to “RogueWave” and change “OpenMPI” to “OpenMP”
  • Page 255: mention that the use of std::string may not be binary compatible between different compilers.
  • Page 273: change “units or any parameters” to “units of any parameters”
  • Page 292: “uses cases” should be “use cases”
  • Page 295: in the StringToDouble() function change “&result” to “*result” and in the following text change “result reference parameter” to “result pointer parameter”
  • Page 315: move the comment “// assert the function’s postcondition” down one line
  • Page 343: “output out” should be “output”
  • Page 368: remove “#include <string>” from the last example as it’s unnecessary
  • Page 399: FARPROC must be cast to appropriate type before calling
  • Page 403: note that you can only convert a static to dynamic library if it was compiled with -fPIC

1st Edition - First Printing

This section contains information about errors in the first edition of API Design for C++. These errors have been corrected in the second printing. Many thanks to the following people for contributing to this list: Javier Estrada, Ivan Komarov, Dan Smith, QiFo Lin, and Alexandros Gezerlis.

  • Page XX: remove quotes around “I will also use the terms module and component”
  • Page 9: change “#include <string.h>” to “#include <string>”
  • Page 41: add comma after CASE_SENSITIVE in the CaseSensitivity enum.
  • Page 51: pass the lat and lon parameters as pointers, not references, for GetGPSLocation()
  • Page 61: change “accompany source code” to “accompanying source code”
  • Page 66: change “for derived class” to “for derived classes”
  • Page 71: change “as follow” to “as follows”
  • Page 74: in the sentence “This may be useful if the class allocates a limited or costly resources such as a network connection.” replace “resources” with “resource”.
  • Page 79 & 81: move “Mutex mutex” to outside of the function and make it static.
  • Page 79 & 81: replace “ScopedLock(&mutex)” -> “ScopedLock lock(&mutex)”
  • Page 80: In the phrase “the Double Check Locking Pattern” replace “Check” with “Checked”
  • Page 101: Figure 3.7: replace “Subscript” with “Subscribe” (2 instances)
  • Page 114: change “non-etheless” to “nonetheless”
  • Page 132: note that objects can be created on the stack too.
  • Page 155: change “Stack *” to “struct Stack *” for the 3 function declarations
  • Page 179: change “the follow code” to “the following code”
  • Page 163: change “PopAnySack” to “PopAnyStack”
  • Page 181: change “Class HashTable” to “class HashTable”
  • Page 186: change “necessary” to “necessarily”
  • Page 194: change “Currency::~Currency()” to “~Currency()”
  • Page 194: change “unsigned in GetReal()” to “unsigned int GetReal()”
  • Page 205 (Tip): change “file scope-free function” to “file-scope free function”
  • Page 238: change “doubling freeing” to “double freeing”
  • Page 269: change “non-etheless” to “nonetheless”
  • Page 338: change “Perform -> Perforce” to “Perforce”
  • Page 241: change “the important of API reviews” to “the importance of API reviews”
  • Page 243: change “non-backward compatible changes” to “non-backward-compatible changes”
  • Page 314: change “sizeof(void *) == 32” to “sizeof(void *) == 4”
  • Page 353: change “in not quite” to “is not quite”
  • Page 368: change “PLUGIN_FUNC()” to “PLUGIN_FUNC”
  • Page 368: change “CORE_FUNC()” to “CORE_FUNC”
  • Page 387: change “all exiting objects” to “all existing objects”
Buy The Book On
Buy It on Amazon
Buy It On Elsevier

© 2024 Martin Reddy, All Rights Reserved