Dereference operator C++

Started by
0 comments, last by Conner McCloud 18 years, 1 month ago
hi, I got a question, what does it mean when the * is used twice. for example ** what does that mean?
Advertisement
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

This topic is closed to new replies.

Advertisement