Chapter 1 - Review of C++ Basics
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
Deep Copy
The Miranda functions
When does the compiler generate the Miranda functions?
The Miranda functions
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
Lab
Chapter 2 - Dynamic Memory
How to create and destroy heap scalars
How to create and destroy heap arrays
Notes
Constraints on builtin arrays
Lab
Chapter 3 - Namespaces
Scopes in C and C++
What was the goal?
What was the problem?
What solutions were tried?
What is a namespace?
How to create 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
Lab
Chapter 4 - Overloaded operators
How to overload the input operator
How to overload the output operator
Lab Part 1
How to overload the comparison operators
Lab Part 2
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?
Overloaded [] versus builtin []
Lab Part 3
How to overload the arithmetic operators
Lab Part 4
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 Part 5
What you cannot do
Overloaded operators
Chapter 5 - Conversion Functions
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
Lab
Chapter 6 - 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 7 - Inheritance
Inheritance and constructor: base class
Inside a constructor, virtual functions aren't
Inheritance and constructor: derived class
Inheritance and copy constructor: base class
Inheritance and copy constructor: derived class
Inheritance and destructor: base class
Inheritance and destructor: derived class
Why "virtual" should be repeated in the derived class
Inheritance and assignment: base class
Inheritance and assignment: derived class
Why assignment cannot be virtual
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
Pointer substitutability
Reference substitutability
How to prevent slicing
Vtables and vptrs
Lab
Chapter 8 - Exception handling
Error Handling
Notes
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 9 - Inline functions
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 10 - File I/O
How to input from an input stream
How to open a file for writing
How to read a value from a file
How to open a file for reading
Lab
The Standard I/O class hierarchy
Chapter 11 - Templates
The evolution of a function
Function template
Template constraint
Who is the most famous "deducer" in history?
http://www.wikipedia.org/wiki/Deerstalker
Template argument deduction
How to make a default value of a type
Class template
Templates are always located in header files
Lab
Chapter 12 - 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
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
What is a marker?
Types of definition
What is a pointer?
What does find() require from 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 13 - Functors
Can a function retain state information?
How to create an object that behaves like a function
Is it a function or is it a functor?
Lab
Chapter 14 - Smart pointers
Smart pointer
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
Reference-Counted Pointer
Lab
How to choose the kind of smart pointer
Chapter 15 - STL
What is STL?
Kinds of containers
Kinds of iterators
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
The container vector
Notes
list
The container list
Notes
deque
The container deque
set
The container set
Multiset
Maps and pairs
Map
How to put a key/value pair into a map
How to lookup a key in a map
How does std::map::operator[] work?
The container map
multimap
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 16 - Static Members
What is a static data member?
What is a static member function?
Class templates and static data members
Lab
Chapter 17 - 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
Lab
Chapter 18 - Separating interface and implementation
What does Bjarne have to say?
Multiple implementations of one interface
Lab
Chapter 19 - 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?
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
UML Syntax
Chapter 20 - 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 21 - 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 22 - RTTI
How to determine the type of an object at runtime
What's the difference between dynamic_cast and typeid?
Lab
Chapter 23 - Pointers to members
Pointer to non-member function
Pointer to per-class member function
Pointer to per-instance member function
Lab
Chapter 24 - Overloading new/delete
How to overload new and delete for a class
Lab