Pointer to const vs const pointer

The meaning of a pointer to const is the same as the meaning of a reference to const–the object pointed to, or referred to, cannot be changed through such a pointer or reference.

In the case of a pointer, however, we have to distinguish between a pointer to const and a const pointer.

The latter is a pointer that, once initialized, cannot be pointed to anything else (just like a reference). The syntax for these two cases is
Link const * pLink; // pointer to const
const Link * pLink; // pointer to const
Link * const pLink = pInitPtr; // const pointer
So, to this day, declaration are best read right to left.

Resolving technical problems:

Solve your technical problems instantly

We provide Remote Technical Support from Monday to Sunday, 7:00PM to 1:00 AM

Mail your problem details at writeulearn@gmail.com along with your mobile numberand we will give you a call for further details. We usually attend your problems within 60 minutes and solve it in maximum 2 days.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.