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().
1
Notes
3
Code examples
The interaction between const objects and const member functions is a
common exam question.