Lecture overview -- Keyboard shortcut: 'u'  Previous page: Static class members -- Keyboard shortcut: 'p'  Next page: Const member functions - const and mutable -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Abstraction Mechanisms, Part 1 - slide 22 : 36

Const member functions

It is possible to mark a member function as constant

A constant member function is not allowed to change the state of the object.

In addition, it makes sense to call a constant member function on a constant object

point.h
A variant of Point with cached polar representation.
point.cc
The implementation of class Point - with compilation problems.

The problem is that const member functions are not allowed to modify the caching variables.

In the next version - on the following page - we show how to deal with this problem