const int * func() const

Learn about the const for pointer values and how it works for type qualifiers.

Returning a mutable pointer to a const value is useful. The pointed data cannot be modified, unlike const pointers, it is even taken into account by the compiler. As shown below.

Constness of a pointer value

The constness of a pointed value is always taken into account.

Get hands-on with 1200+ tech skills courses.