Study Guide · 03

Const & Static

Immutable members and class-level shared state

const member variables

Must be initialised in the constructor initialiser list. Cannot be modified after construction.

const member functions

Declared with const after the parameter list. Cannot modify any member variable.

static member variables

Shared across all instances. Must be defined once outside the class. Exists even with no objects.

static member functions

Can only access static members — no this pointer. Called via ClassName::method().

2

Videos by Dr. Ibrahim Albluwi

The interaction between const objects and const member functions is a common exam question.