Chapter 1 - Review of C++ Basics
Standard preprocessor symbols
How to name a value
How to pass objects from function to function
The meaning of const
Mixing const and pointers
The origin of "this"
How to send a message to a const object
Default parameter value
How to invoke a constructor
How to copy an object
Shallow Copy
What are two ways that shallow copy could cause a problem?
Deep Copy
The Miranda functions
When does the compiler generate the Miranda functions?
The Miranda functions
Why can't the compiler always delete?
When should you implement which function?
How to default a special member function
Compiler-generated functions are always public, inline, and nonvirtual
How to delete a special member function
How to delete an in-bound conversion
How to specify an abstract public base class
Value Semantics versus Reference Semantics
How to disable copy and assignment, version 1
How to disable copy and assignment, version 2
How to disable copy and assignment, version 3
Who can invoke private functions?
How to disable copy and assignment, version 4
How to disable copy and assignment, version 5
How to disable copy and assignment, version 6
Lab
Chapter 2 - C++11 Basics
What are the character types?
What are the integral types?
What are the signed integral types?
What are the unsigned integral types?
What are the floating point types?
What are the arithmetic types?
What are the fundamental types?
What is a literal?
What are the literal prefixes?
What are the digit separators?
What are the literal suffixes?
What is a string literal?
What is a raw string literal?
How to convert from a number to a string
What is a constant_expression?
What is a const variable?
What is a constexpr variable?
What is a constexpr function?
What is a literal type?
Where do we need to use a constant_expression?
How to assert at compile-time
What is a delegating constructor?
Standard compiler-defined symbols
Lab
Chapter 3 - How to deduce the type of a variable
How to deduce the type of a variable from an initializer
How to deduce the type of a variable from an expression
What are the differences between auto and decltype?
Lab
Chapter 4 - How to deduce the return type of a function
Requirements
Lab
Chapter 5 - Range-Based For Statement
How to iterate-to-read an initializer list
How to iterate-to-read a builtin array
How to iterate-to-read a container
How to iterate-to-write a builtin array
How to iterate-to-write a container
Lab
Chapter 6 - How to initialize a variable
What is uniform initialization?
How to prevent narrowing during initialization
How to use a range for statement to iterate-to-read an initializer list of
values
How to initialize a variable
How to initialize a data member
How to initialize a non-static array data member
How to initialize a static data member
Always use brace initialization, except
Lab
Chapter 7 - Dynamic Memory
Memory
How to create and destroy heap scalars
How to create and destroy heap arrays
When can an array have 0 elements?
What is the sizeof() an object with no data members?
Constraints on builtin arrays
Lab
Chapter 8 - Move Semantics
How to copy a resource
When is copying a resource unnecessary?
Wouldn't it be easier to move the resource, rather than copy it?
When is copying a resource unnecessary?
What is an lvalue?
What is an rvalue?
What is a reference?
What is an lvalue reference?
What is an rvalue reference?
How to convert an lvalue reference to an rvalue reference
How to use rvalue references to determine when to copy and when to move
How function overloading chooses when to copy and when to move
When does the compiler synthesize the move operations?
How to move-enable other member functions
How to convert an lvalue reference to an rvalue reference
How to use a reference qualifier
Overloading
Lab
Chapter 9 - Namespaces
Scopes in C++
What was the goal?
What was the problem?
What solutions were tried?
What is a namespace?
How to create a namespace
How to add a non-member function to a namespace
How to nest namespaces
How to choose which namespace to use
The namespace std
Using directives in header files
Using directives/declarations in file scope
Definitions that are not inside a namespace
How to invoke a function in the global scope
Unnamed namespace
Lab
Chapter 10 - Overloaded operators
Syntactic sugar
Anonymous Temporary
Why is operator+ a non-member function?
How to chain (a.k.a. cascade) operator+
Why is operator>> a non-member function?
How to overload the input operator
Why is operator<< a non-member function?
How to overload the output operator
How to overload the comparison operators
What does (x < y) mean?
How to overload the subscript operator
How to overload the subscript operator for const objects
How to overload the subscript operator for const and non-const objects
Isn't this illegal overloading?
4 ways to invoke operator[]()
Overloaded [] versus builtin []
How to overload the arithmetic operators
Why does operator+() have a by-value return?
What does (x + y) mean?
How to overload the increment operator, version 1
How to overload the increment operator, version 2
How to overload the increment operator, version 3
How to overload the increment operator, version 4
Lab
Arithmetic operators
What you cannot do
Member or Non-Member?
Overloaded operators
Chapter 11 - Conversion Functions
How to convert from one type to another type
What is a cast?
How to enable a one-parameter constructor to be used as an inbound conversion
function
How to disable a one-parameter constructor to be used as an inbound
conversion function
Outbound conversion function
You can define multiple outbound conversion functions
What does x = 3 mean?
Lab
Chapter 12 - How to add a data member
How to add a data member
Unaffected
Member initialization list
When am I required to use a member initialization list?
When am I unable to use a member initialization list?
Lab
Chapter 13 - Inheritance
How to prevent a class from having derived classes
Inheritance and constructor: base class
Inside a constructor, virtual functions aren't
Inheritance and constructor: derived class
How to inherit a base class's constructors
Inheritance and copy constructor: base class
Inheritance and copy constructor: derived class
Why copy() cannot be virtual
Inheritance and destructor: base class
Inheritance and destructor: derived class
Why "virtual" should be repeated in the derived class
Inheritance and copy assignment: base class
Inheritance and copy assignment: derived class
Why operator=() cannot be virtual
How to add an overload to a base class's member function, the wrong way
How to add an overload to a base class's member
How to override a function the wrong way
How to override a function the right way
How to prevent a virtual function from being overridden
How to prevent a non-virtual function from being redefined
Inheritance and input from a stream: base class
Inheritance and input from a stream: derived class
Why we don't need to overload operator>> in the derived class
Inheritance and output to a stream: base class
Inheritance and output to a stream: derived class
Why we don't need to overload operator<< in the derived class
Static type versus dynamic type
Non-virtual, virtual, and pure virtual functions
Forbidden, Permitted, Required
Substitutability
Instance substitutability
Why slicing is evil
Pointer substitutability
Reference substitutability
How to prevent slicing
How do I make a class abstract?
Vtables and vptrs
Lab
Chapter 14 - Exception handling
Error Handling
assert
What is an exception?
try, catch, throw
How to throw a value of builtin type
How to throw a value of class type
How to catch more than one type of exception
How to throw a value of class type: inheritance
Can a function say what it throws?
What happens to local variables of class type?
What happens to heap variables?
A common use of catch (...)
Lab
Chapter 15 - Inline functions
The evolution of a function
Why should I use a #define macro instead of a function?
The evolution of a function
Why should I not use a #define macro instead of a function?
The evolution of a function
How to inline a non-member function
How to inline a member function, #1
How to inline a member function, #2
Why a compiler might ignore "inline"
Reasons to not inline a function
Lab
Chapter 16 - File I/O
Two type of input/output
How to input from an input stream
How to do formatted output
How to read a value from a file
How to do formatted input
How to do unformatted output
How to do unformatted input
Lab
The Standard I/O class hierarchy
Chapter 17 - Templates
The evolution of a function
Function template
Template constraint
How to deduce the return type of a function from an expression
Who is the most famous "deducer" in history?
Template argument deduction
Anonymous Temporary
How to make a default value of a type
Class template
Templates are always located in header files
Before C++11:
How to create an alias for a template type
How to delete one template specialization
Variable Templates
Lab
How can the compiler help you identify the template constraints?
Chapter 18 - How to generalize a function
The find algorithm, version 1
Constraints, version 1
Transformation
The find algorithm, version 2
Constraints, version 2
How to know when to stop looking
Accessing builtin array elements
The Phantom Element
Transformation
The find algorithm, version 3
Constraints, version 3
Transformation
The find algorithm, version 4
Constraints, version 4
Transformation
The find algorithm, version 5
Constraints, version 5
Types of definition
What is a whiteboard marker?
What is a C++ pointer?
What does find() require from C++ pointers?
Replacing builtin pointers with iterators
Do we need two overloads of find()?
Transformation
The find algorithm, version 6
Constraints, version 6
Container
Transformation
The find algorithm, version 7
Constraints, version 7
Who makes the iterators?
The container makes the iterators
Who names the iterator type?
The container names the iterator type
Iterators nested inside Containers
Why bother having a public typedef to a private nested class?
Algorithms, Iterators, and Containers
Algorithms do not have to start at the begin() and stop at the end()
find() and std::find()
Lab
Chapter 19 - Functors
How to create an anonymous temporary function
How to add a data member to an anonymous temporary function
Is it a function or is it a functor?
Lab
Chapter 20 - Lambda Expressions
What is a lambda expression?
A lambda is syntactic sugar for a functor
How to add an input parameter to a lambda
How to add a data member to a lambda
How to capture by-value
How to modify a captured copy
How to add a reference data member to a lambda
How to capture by-reference
More about lambda capture
How to return a value from a lambda expression
How to capture this
What is an implicit capture?
Why would I need to capture?
Should I use a function or a lambda expression?
How to deduce the type of a lambda formal parameter
Lab
Chapter 21 - std::function
What is a call signature?
How to say "function that returns type Tr and takes types T1, T2, T3, ...,
Tn"
Lab
Chapter 22 - Smart pointers
Smart pointer
How to send a message through a smart_ptr
How to send a message through a smart_ptr, the wrong way
How to send a message through a smart_ptr, the right way
Iterator
How to limit the lifetime of a heap variable
Scoped pointer
When a scoped_ptr is not enough
Auto pointer
How to use an auto_ptr
How not to use an auto_ptr
What is a std::unique_ptr?
What happens with a std::unique_ptr is destructed?
How to use a unique_ptr to an array
Reference-Counted Pointer
Lab
What is a std::shared_ptr?
What happens with a std::shared_ptr is destructed?
How to use a shared_ptr to an array
How to choose the kind of smart pointer
Chapter 23 - STL
What is STL?
What is a container?
Categories of containers
Categories of iterators
What is an array?
What is a vector?
What is a deque?
What is a forward_list?
What is a list?
What is a set?
What is a multiset?
What is a map?
What is a multimap?
What is an unordered_set?
What is an unordered_multiset?
What is an unordered_map?
What is an unordered_multimap?
What is a stack?
What is a queue?
What is a priority_queue?
Standard header files:
What is the type of element?
What is the type of key?
What is the type of the size?
What is the type of pointer to element
What is the type of iterator to element
What is the type of reverse iterator to element
What is the type of reference to element
What is the type of the maximum difference
How to construct a container: default constructor
How to construct a container from n elements each of which is T{}
How to construct a container from n elements each of which is a copy of
a_value
How to construct a container from a range of iterators
How to construct a container from an initializer list
How to construct a container: copy-constructor
How to construct a container: move-constructor
How to copy-assign a container from n elements each of which is a copy of
a_value
How to copy-assign a container from a range of iterators
How to copy-assign a container from an initializer list
How to copy-assign a container
How to move-assign a container
How to destruct a container
Is the container empty?
How to get the size
How to get the maximum size
How to get an iterator to the first element
How to get an iterator to one after the last
How to get a reverse iterator to the last element
How to get a reverse iterator to one after the
How to get a reference to the first element
How to get a reference to the last element
How to compare two containers
How to access the n'th element
How to lookup one element
How to add one or more elements to a container
How to remove one or more elements from a container
How to remove all of the elements from a container
How to swap the elements of two containers of the same type
How to sort the elements of a container
Special: array
How to grow a vector, the slow way
How to grow a vector, the fast way
How to have constant cost growth
vector's implementation
vector: sample usage
Special: vector
Special: deque
Special: forward_list
Special: list
set: sample usage
Special: set
Special: multiset
pair
A map is implemented as a balanced binary search tree
How to add a key/value pair to a map
How to lookup a key in a map
How to modify a key's value in a map
How does std::map::operator[] work?
map: sample usage
Special: map
Special: multimap
Special: unordered_set
Special: unordered_multiset
Special: unordered_map
Special: unordered_multimap
Special: stack
Special: queue
Special: priority_queue
How to choose a container
How to make your own algorithm
How to improve the readability of compiler error messages pertaining to STL
Lab
Chapter 24 - Variadic Templates and Parameter Packs
How to pass different numbers of arguments of the same type to the same
function
How to pass different numbers of arguments of different types to the same
function
The wrong way
The right way - use a variadic template
How to access the n'th argument of a variadic template
The wrong way
The right way
What if you don't need a separate overload for each single type?
How pass arguments by-reference - the wrong way
How pass arguments by-reference - the right way
How pass arguments by-reference-to-const - the right way
Lab
Chapter 25 - Static Members
Per-instance versus per-class
What is a static data member?
What is a static member function?
Class templates and static data members
Lab
Chapter 26 - Private inheritance
Public inheritance
When NOT to use public inheritance
Private inheritance
When to use private inheritance
Why not use composition?
Why use private inheritance instead of composition?
Alignment
How to restore the visibility of an inherited member
Relationships
Lab
Chapter 27 - Separating interface and implementation
What does Bjarne have to say?
How to evolve a class into an interface, 0
How to evolve a class into an interface, 1
How to evolve a class into an interface, 2
How to evolve a class into an interface, 3
How to evolve a class into an interface, 4
How to evolve a class into an interface, 5
What is an interface?
Where should we use interfaces?
Lab
Chapter 28 - Multiple inheritance
Can a class have more than one superclass?
What is multiple inheritance?
Example: Multiple inheritance
Do I inherit attributes multiple times?
Do I inherit operations multiple times?
Resolving ambiguity
Should I avoid multiple inheritance?
The Diamond of Death
Multiple Inheritance on "Saturday Night Live"
What to do if multiple inheritance is inappropriate
How do I say "multiple inheritance" in UML?
Some good examples of multiple inheritance
Bank accounts - the wrong way
Bank accounts - a better way
Mixin class
Lab
Chapter 29 - Friend
What is a friend?
How to grant friendship to a non-member function
How to grant friendship to a member function
How to grant friendship to all the member functions in a class
Why isn't friendship used more widely?
Lab
Chapter 30 - Cast operators
The cast operator
The static_cast operator
The reinterpret_cast operator
The const_cast operator
How to do an unsafe downcast
The dynamic_cast operator
Bad practice use of dynamic_cast
Good practice use of dynamic_cast
Lab
Chapter 31 - RTTI
How to determine the type of an object at runtime
What's the difference between dynamic_cast and typeid?
Lab
Chapter 32 - Pointers to members
Pointer to non-member function
Pointer to per-class member function
Pointer to per-instance member function
Lab
Chapter 33 - Overloading new/delete
Under the covers with new and delete
How to overload new and delete for a class
Lab
Chapter 34 - enum
Pre-C++11 enum
C++11 enum
Lab
Chapter 35 - Threads and Concurrency
What is concurrency?
How to start a thread to a non-member function
How to do it wrong
How to start a thread to a member function
How to start a thread to a functor
How to start a thread to a lambda
How to pass by-value to a thread
Reference Wrapper
How to pass-by-reference to a thread
How to pass by-reference-to-const to a thread
How to return a value from a thread
How to share data between threads
What is a conflict?
What are the possible memory orders?
std::atomic_flag and spin_lock_mutex
How to guarantee to unlock the mutex
std::atomic_flag and spin_lock_mutex ==> std::mutex
std::atomic
References
Lab
Chapter 36 - Unit Testing and Test-Driven Development
What is Unit Testing?
Unit Testing Frameworks
What is Test-Driven Development (TDD)?
The TDD Cycle
Red and Green
The TDD Cycle
How to make a master test suite
How to make a test case
How should a test case, test?
How to write a test case that should fail
One master test suite can contain multiple test cases
What should a test case, test
One master test suite can contain multiple test suites
How to refactor commonality into a test fixture
What should I do next?
References
Lab
Chapter 37 - C++11 Features
Removed
Deprecated
Introduced
Chapter 38 - C++14 Features
Removed
Deprecated
Introduced
Chapter 39 - C++17 Features
Removed
Deprecated
Introduced