C++20 sections · 1024 units
Open in Course

What is a Class?

User-defined types

A class defines a custom type that groups related data and operations. Think of it as a blueprint: just as architectural plans describe a house without being a house, a class describes objects without being one.

You specify what data the type holds and what operations it supports. A Rectangle class might store width and height, then provide functions to calculate area or perimeter. This bundles related pieces into a single unit instead of managing disconnected variables and functions across your codebase.