Module 04 of 10

Classes & OOP

Lessons

About This Module

A class bundles data and the functions that work on it into a single type, and it is how C++ programs model real things. This module starts with classes vs. structs — the only real difference is default visibility — and how to decide which one to use.

It then moves to polymorphism: how virtual functions let code written against a base class call the right derived version at runtime, and how interfaces built from pure virtual functions force every subclass to provide an implementation. The last lesson covers virtual destructors, a small detail that prevents memory leaks whenever you delete a derived object through a base class pointer.

Watch the lessons in order, then continue on to Templates & Generic Programming.

Lessons

4 videos
01

CLASSES vs STRUCTS in C++

What actually separates a class from a struct (default visibility), and when the Cherno prefers each one.

02

Virtual Functions in C++

How a base class pointer can call a derived class's version of a function, how the override keyword helps, and what virtual functions cost.

03

Interfaces in C++ (Pure Virtual Functions)

How pure virtual functions turn a base class into an interface that cannot be instantiated and forces subclasses to implement it.

04

Virtual Destructors in C++

Why a base class destructor must be virtual, so that deleting a derived object through a base pointer cleans up correctly and does not leak memory.