std::vector<Enemy*>::iterator it;
for(it;it!=tracked.end();it++){
(*it)->update(timeSinceLastFrame);
}
tracked
is the vector:
std::vector<Enemy*>
Why am I getting this error? (please say if I haven't included enough details)
You never initialized the iterator.
for(std::vector<Enemy*>::iterator it = tracked.begin();it!=tracked.end();it++){
(*it)->update(timeSinceLastFrame);
}
Many implementations (such as VC++, which you appear to be using) perform checks in debug to make sure that when two iterators are compared, they belong to the same object. A default constructed iterator does not belong to any particular instance, and as such the it != tracked.end()
check will fail with that error.
You haven't initialized it
. Try this:
std::vector<Enemy*>::iterator it;
for(it=tracked.begin();it!=tracked.end();it++){
(*it)->update(timeSinceLastFrame);
}
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.