Return const Pointers

Learn about returning const pointers.

We'll cover the following

Pointers are similar to references in the sense that the pointed object must be alive at least as long as the caller wants to use it. We can return the address of a member variable if we know that the owning object will not get destroyed considering the caller wants to dereference the pointer. It is important to emphasize that we should never return a pointer to a local variable.

However, that is not self-evident. Let’s step back a little bit.

Get hands-on with 1200+ tech skills courses.