...

/

const ref Parameters

const ref Parameters

Learn about the const ref parameters and non-const member functions.

This lesson is about how parameters and member functions are marked as const so that they can be used with immutable variables as well.

Although the examples in this lesson use only structs, const member functions also apply to classes.

immutable objects

You have already seen that it is not possible to modify immutable variables:

immutable readingTime = TimeOfDay(15, 0);

readingTime cannot be modified:

 ...