Classes and RAII
This part of the C++ course is where a program starts to own something. A class with an invariant comes first, then the constructor and the destructor that release a resource, the member initializer list and the two rules that tie copying to moving. The class becomes a value type through const member functions and operator overloading, and the part closes with inheritance, virtual dispatch and an abstract interface that a program depends on through a reference.
3.1
Classes and objects
members, access control, member functions, this, and a class that keeps its invariant
Open
3.2
Constructors and destructors
default, converting and copy constructors, the destructor, and the order of construction
Open
3.3
Member initializer lists
initialise members in declaration order, const and reference members, and the cost of assignment in a body
Open
3.4
RAII
tie a resource to an object, release it in the destructor, and survive an early return or an exception
Open
3.5
Static members
class-level state, static member functions, inline static data and a counter that survives objects
Open
3.6
const member functions and mutable
which functions may be called on a const object, overloading on const, and mutable caches
Open
3.7
Operator overloading
operator+, ==, <<, [] and += on a value type, and the rules that keep them predictable
Open
3.8
Copy constructors and copy assignment
the compiler-generated copy, deep copies of a buffer, self-assignment and the rule of three
Open
3.9
Move constructors and move assignment
rvalue references, stealing a buffer, std::move and the state of a moved-from object
Open
3.10
The rule of zero and the rule of five
own nothing and write nothing, or write all five operations, and why the middle ground breaks
Open
3.11
Inheritance
derive a class, call the base constructor, protected members, name hiding and object slicing
Open
3.12
Virtual functions and polymorphism
virtual dispatch, override, final, virtual destructors and the cost of a vtable
Open
3.13
Abstract classes and interfaces
pure virtual functions, an interface with no data, dependency injection through a reference
Open