Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the meaninings of two ** for an iterator

In the following code segment

vector<SceneObject *> sceneObjs;
vector<SceneObject *>::iterator iter;

iter = sceneObjs.begin();
while (iter != sceneObjs.end()){
  cout << **iter <<endl;
  iter++;
}

why **iter has two *s ?

like image 441
user785099 Avatar asked Nov 27 '22 07:11

user785099


1 Answers

The first * dereferences the iterator, giving a SceneObject * pointer. The second * dereferences this SceneObject * pointer to the SceneObject itself.

like image 98
Rudi Avatar answered Dec 20 '22 14:12

Rudi