In my C++ project I have a class called Trap. A Trap is an NPC and an NPC is an Entity. Now I want to loop through all NPC's and do stuff with them. For example, I want a Trap to update. I do that in the following way.
for (vector<NPC>::iterator it = Enemies.begin(); it != Enemies.end(); ++it) {
it->Update();
}
But now the Update() call is calling the NPC::Update() method.
I'm confident this is because of the way I used the iterator, but I don't know how to better do this. Use a different kind of iteration? Is there a simple trick for this?