Sign in to follow this  
Ksingh30

Dereference operator C++

Recommended Posts

It dereferences the results of the previous dereference.

int a;
int* pa = &a;
*pa == a;
int** ppa = &pa;
*ppa == pa;
**ppa == *pa == a;


*edit: Naturally, you can do this indefinately.

int*** pppa = &ppa;
*pppa == ppa;
**pppa == *ppa == pa;
***ppa == **ppa == *pa == a;

However, think long and hard if you ever find yourself needing more than two dereferences at a time. There's a chance something is more complicated than it needs to be.

CM

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this