Tech Book: A Tour of C++, Bjarne Stroustrup

A Tour of C++ This recent book was recommended by Herb Sutter at CppCon as a slim summary of all that C++ developers should be expected to know. It’s a good read, sprinkled liberally with example code to illustrate the techniques that make up modern C++. Having originally learn C++98, then spent a lot of time reading and trying our C++11 techniques, it’s interesting to see how the language looks when presented as a whole. Also, the book covers some C++14 additions.

The points I particularly found interesting were:

  • override – use this to mark virtual methods that are declared in the base class and have an implementation in the derived class (avoids declaring a new virtual method if the signature is wrong)
  • explicit – single argument constructors should by default be marked as explicit to avoid unexpected implicit conversions, unless there’s a reason not to
  • delete – when defining a base class, it’s good practice to ‘delete’ the default copy and move operations, given that the default implementations will not know how to handle derived class members
  • regex – the book covers the standard library as well as the language. A welcome addition is std::regex, and the chapter in this book is an excellent introduction
  • vector initialisation – uniform initialisation of vectors of a struct can still use initialiser lists, even if the struct members have different types e.g. string/int
  • vector::at – this method returns the same value as operator[] (subscript), but performs bounds-checking, which doesn’t happen with operator[]

Four Stars

Leave a comment

Filed under C++, Tech Book

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s