简体   繁体   中英

Very Basic std::vector iterating

std::vector<Ogre::SceneNode*>::iterator itr;
for(itr=mSelectedObjects.begin();itr!=mSelectedObjects.end();itr++){
    itr->showBoundingBox(true); //here
}

I'm getting "expression must have pointer-to-class type" on the marked line, and I'm not sure why. Can anyone help?

Replace the erroneous line with:

(*itr)->showBoundingBox(true); //here

Since you're storing pointers, you need to dereference itr twice to get from the iterator to the object (once for the iterator and once for the pointer).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM