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.

024 Classes and objects members, access control, member functions, this, and a class that keeps its invariant Open 025 Constructors and destructors default, converting and copy constructors, the destructor, and the order of construction Open 026 Member initializer lists initialise members in declaration order, const and reference members, and the cost of assignment in a body Open 027 RAII tie a resource to an object, release it in the destructor, and survive an early return or an exception Open 028 Static members class-level state, static member functions, inline static data and a counter that survives objects Open 029 const member functions and mutable which functions may be called on a const object, overloading on const, and mutable caches Open 030 Operator overloading operator+, ==, <<, [] and += on a value type, and the rules that keep them predictable Open 031 Copy constructors and copy assignment the compiler-generated copy, deep copies of a buffer, self-assignment and the rule of three Open 032 Move constructors and move assignment rvalue references, stealing a buffer, std::move and the state of a moved-from object Open 033 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 034 Inheritance derive a class, call the base constructor, protected members, name hiding and object slicing Open 035 Virtual functions and polymorphism virtual dispatch, override, final, virtual destructors and the cost of a vtable Open 036 Abstract classes and interfaces pure virtual functions, an interface with no data, dependency injection through a reference Open

Lessons