int * const func() const

Learn about the `const` with return pointers.

What happens when both the function and the returned pointer are const, but the data we point to is modifiable? Returning a const pointer doesn’t make sense because the const will be ignored. Luckily the compiler also tells us this directly.

How constness of the returned pointer works?

But how does this const pointer work in practice? Let’s look at an example where the constness of a returned pointer is ignored.

Get hands-on with 1200+ tech skills courses.