Study Notes

C++ Programming Notes

A self-contained reference book covering the fundamentals of C++

01

Getting Started

What C++ is, how source code becomes an executable, and the trade-offs of the language.

compilation linking object files advantages
02

The Anatomy of a C++ Program

Preprocessor directives, namespaces, functions, and standard I/O with iostream.

#include namespace std::cout std::cin getline
03

Variables, Constants & Additional Topics

Primitive types, overflow, constants, enums, type deduction, and memory layout.

primitives const constexpr enum auto memory layout
04

Managing Arrays and Strings

Static and dynamic arrays, multidimensional arrays, array decay, C-strings, std::string, std::array, and std::vector.

static arrays multidimensional c-strings std::string std::vector
05

Expressions, Statements and Operators

Arithmetic, comparison, logical, increment/decrement, compound assignment, bitwise operators, and std::bitset.

arithmetic comparison logical bitwise std::bitset ++/--
06

Controlling Program Flow

if/else, while, do-while, for, range-based for, break, continue, switch/case, ternary operator, and goto.

if/else for while switch ternary break/continue
07

Organizing Code with Functions

Prototypes, extern linkage, default values, pass by reference, function stacks, inline, overloading, name mangling, and overload resolution.

prototypes overloading inline extern name mangling call stack
08

Pointers and References

Pointers, dynamic allocation, delete, const pointers, nullptr, placement new, references, resource management, and smart pointers.

pointers new/delete references nullptr smart pointers RAII
09

Classes and Objects

Encapsulation, access specifiers, constructors, init lists, destructors, copy/move semantics, object initialization, static members, const member functions, mutable, friends, unions, and the this pointer.

constructors copy/move Rule of Five static mutable friend this
10

Return Value Optimization

How the compiler eliminates unnecessary copies on return — RVO, NRVO, Copy Elision, and when these optimizations don't apply.

RVO NRVO copy elision
11

Alignment

Type sizes, alignment boundaries, struct padding, member ordering, #pragma pack, empty class size, and cache architecture.

alignment padding struct layout cache lines #pragma pack
12

Inheritance

Public, protected and private inheritance, base class initialization, overriding, slicing, multiple inheritance, and copy/assignment in derived classes.

is-a / has-a override slicing multiple inheritance final
13

Polymorphism

Virtual functions, vtables, abstract base classes, pure virtual functions, the diamond problem, and override/final specifiers.

virtual vtable pure virtual ABC diamond problem
14

OOP Design Principles

Template Method and Strategy patterns, non-member non-friend functions, conversion design, and exceptions in destructors.

NVI strategy pattern non-member functions conversions
15

Operator Overloading

Unary and binary operators, equality, subscript, function operator, move assignment, conversion operators, and user-defined literals.

unary/binary operator[] operator() move = UDL
16

Casting

C-style casts vs C++ casts — static_cast, dynamic_cast, reinterpret_cast, const_cast, and volatile.

static_cast dynamic_cast reinterpret_cast const_cast volatile
17

Macros

What macros are, include guards, function macros, assert, and when to prefer consts, enums, and inlines.

#define include guards assert #pragma once enum hack
18

Templates & Tuples

Template functions and classes, specialization, variadic templates, static_assert, generic programming, and std::tuple.

template specialization variadic static_assert std::tuple