# C++ Object-Oriented Programming

> A complete curriculum on C++ Object-Oriented Programming: classes, constructors, encapsulation, inheritance, polymorphism, abstraction, copy semantics, and the Rule of Three, Five, and Zero.

- Canonical URL: https://shafinchowdhury.dev/topics/cpp-oop/
- Author: Shafin Chowdhury (https://shafinchowdhury.dev/about/)

Object-Oriented Programming in C++ combines zero-cost abstractions with precise hardware-level control over memory, object lifetimes, and runtime dispatch. This curriculum provides a rigorous, step-by-step learning path—starting with foundational class blueprints and memory encapsulation, progressing through inheritance and dynamic polymorphism, and culminating in resource management, copy semantics, and the Rule of Three, Five, and Zero.

## Curated Learning Path

1. **[Beginner]** [Classes and Objects in C++](https://shafinchowdhury.dev/posts/cpp-classes-and-objects/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-classes-and-objects.md)) — User-defined blueprints, object state and behavior, access specifiers, and the this pointer.
2. **[Beginner]** [Constructors and Destructors in C++](https://shafinchowdhury.dev/posts/cpp-constructors-and-destructors/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-constructors-and-destructors.md)) — Default and parameterized constructors, member initializer lists, object lifecycle, and RAII foundations.
3. **[Beginner]** [Encapsulation in C++](https://shafinchowdhury.dev/posts/cpp-encapsulation/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-encapsulation.md)) — Data hiding, getters and setters, maintaining invariants, and protecting internal state.
4. **[Intermediate]** [Inheritance in C++](https://shafinchowdhury.dev/posts/cpp-inheritance/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-inheritance.md)) — Base and derived classes, access levels, constructor call order, and modeling is-a relationships.
5. **[Intermediate]** [Polymorphism in C++](https://shafinchowdhury.dev/posts/cpp-polymorphism/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-polymorphism.md)) — Compile-time vs runtime polymorphism, virtual functions, dynamic dispatch, override, and virtual destructors.
6. **[Intermediate]** [Abstraction in C++](https://shafinchowdhury.dev/posts/cpp-abstraction/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-abstraction.md)) — Abstract classes, pure virtual functions, building pure interfaces, and decoupling systems.
7. **[Intermediate]** [Function Overloading vs Function Overriding](https://shafinchowdhury.dev/posts/cpp-function-overloading-vs-overriding/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-function-overloading-vs-overriding.md)) — Compile-time signatures, runtime dynamic dispatch, comparison metrics, and derived-class name hiding.
8. **[Intermediate]** [Composition vs Inheritance](https://shafinchowdhury.dev/posts/cpp-composition-vs-inheritance/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-composition-vs-inheritance.md)) — Has-a vs is-a design trade-offs, coupling dynamics, fragile base classes, and reusability.
9. **[Advanced]** [Copy Constructor in C++](https://shafinchowdhury.dev/posts/cpp-copy-constructor/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-copy-constructor.md)) — Object duplication mechanics, pass-by-value triggers, const reference parameters, and copy assignment contrast.
10. **[Advanced]** [Shallow Copy vs Deep Copy in C++](https://shafinchowdhury.dev/posts/cpp-shallow-copy-vs-deep-copy/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-shallow-copy-vs-deep-copy.md)) — Pointer aliasing traps, double-free crashes, memory ownership, and allocating dedicated heap resources.
11. **[Advanced]** [Rule of Three, Five and Zero in C++](https://shafinchowdhury.dev/posts/cpp-rule-of-three-five-zero/) ([Markdown](https://shafinchowdhury.dev/posts/cpp-rule-of-three-five-zero.md)) — Historical resource management progression, move semantics (rvalues), and modern RAII Rule-of-Zero design.

## Articles by Category

### 1. Foundations

Core mental models, class blueprints, object lifecycle, and robust data protection.

- [C++ Classes and Objects: A Beginner's Guide](https://shafinchowdhury.dev/posts/cpp-classes-and-objects/): C++ classes and objects: a class is a user-defined type that groups data and functions, and an object is one instance of it. Learn syntax and access specifiers. ([Markdown](https://shafinchowdhury.dev/posts/cpp-classes-and-objects.md))
- [C++ Constructors and Destructors Explained](https://shafinchowdhury.dev/posts/cpp-constructors-and-destructors/): Master object lifecycle in C++. Learn default and parameterized constructors, member initializer lists, destructor execution order, and RAII foundations. ([Markdown](https://shafinchowdhury.dev/posts/cpp-constructors-and-destructors.md))
- [C++ Encapsulation: Data Hiding, Getters and Setters](https://shafinchowdhury.dev/posts/cpp-encapsulation/): Master encapsulation in C++. Understand how bundling state with behaviors, data hiding, and invariant validation protect your software from state corruption. ([Markdown](https://shafinchowdhury.dev/posts/cpp-encapsulation.md))

### 2. Reusing and Extending Classes

Class hierarchies, access mechanics, base initialization, and architectural composition trade-offs.

- [C++ Inheritance: Base Classes, Derived Classes and Access](https://shafinchowdhury.dev/posts/cpp-inheritance/): Learn C++ inheritance from the ground up. Understand base and derived classes, access behavior under public inheritance, constructor call order, and the is-a relationship. ([Markdown](https://shafinchowdhury.dev/posts/cpp-inheritance.md))
- [Composition vs Inheritance in C++: Object Design Trade-Offs](https://shafinchowdhury.dev/posts/cpp-composition-vs-inheritance/): Composition vs inheritance in C++: inheritance models is-a, composition models has-a. Compare coupling, flexibility and reuse, and learn when to use each. ([Markdown](https://shafinchowdhury.dev/posts/cpp-composition-vs-inheritance.md))

### 3. Polymorphism and Abstraction

Static vs dynamic dispatch, virtual tables, pure interfaces, and overloading vs overriding.

- [C++ Polymorphism: Compile-Time vs Runtime Polymorphism](https://shafinchowdhury.dev/posts/cpp-polymorphism/): Master polymorphism in modern C++. Understand compile-time vs runtime polymorphism, virtual functions, dynamic dispatch, the override specifier, and virtual destructors. ([Markdown](https://shafinchowdhury.dev/posts/cpp-polymorphism.md))
- [C++ Abstraction: Abstract Classes and Pure Virtual Functions](https://shafinchowdhury.dev/posts/cpp-abstraction/): Master abstraction in C++. Learn how pure virtual functions and abstract classes decouple interfaces from implementations using a complete payment gateway system. ([Markdown](https://shafinchowdhury.dev/posts/cpp-abstraction.md))
- [Function Overloading vs Function Overriding in C++](https://shafinchowdhury.dev/posts/cpp-function-overloading-vs-overriding/): Function overloading vs overriding in C++: overloading reuses a name with new parameters at compile time; overriding redefines a virtual function at runtime. ([Markdown](https://shafinchowdhury.dev/posts/cpp-function-overloading-vs-overriding.md))

### 4. Object Copying and Resource Management

Copy construction, memory ownership, shallow vs deep copies, and the modern Rule of Three, Five, and Zero.

- [C++ Copy Constructor: How Object Copying Works](https://shafinchowdhury.dev/posts/cpp-copy-constructor/): Master the C++ copy constructor. Understand copy initialization, why parameters require const references, the difference from operator=, and resource ownership. ([Markdown](https://shafinchowdhury.dev/posts/cpp-copy-constructor.md))
- [C++ Shallow Copy vs Deep Copy Explained](https://shafinchowdhury.dev/posts/cpp-shallow-copy-vs-deep-copy/): Understand the vital difference between shallow copy and deep copy in C++. Learn how pointer copying causes double deletion and how to implement custom deep copying. ([Markdown](https://shafinchowdhury.dev/posts/cpp-shallow-copy-vs-deep-copy.md))
- [Rule of Three, Five and Zero in C++: Resource Management](https://shafinchowdhury.dev/posts/cpp-rule-of-three-five-zero/): Master modern C++ resource management. Understand the historical evolution from the Rule of Three to move semantics in the Rule of Five, and why the Rule of Zero is the gold standard. ([Markdown](https://shafinchowdhury.dev/posts/cpp-rule-of-three-five-zero.md))
