frendall frendall - 3 years ago 97
C++ Question

Match a variable with an iterater using a vector object array

I have an iterator

and a variable
. I am trying to match
with the iterator. I would appreciate any help or advice.
Thanks in advance.

for(ic = ackAttacky.begin();ic !=ackAttacky.end())
if(alien[ncount].alienBulletDead == true){
ic = ackAttacky.erase(ic);
alien[ncount].alienBulletDead = false;
alien[ncount].alienFired = false;
alienBulletCounter -=1;
cout << ncount << " " << ackAttacky.size() << endl;

Answer Source

How about std::distance?

nCount = std::distance(ackAttacky.begin(), ic);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download