The two vectors contain pointers of base class actor, which are used to point to members of two derived classes (player and enemy) and polymorphically call the Update function from the current Enemy, with the current player as an argument.
I believe I have to use pointers, to allow polymorphism (though I read references could be used also, I'd love to be able to do that) since Player's Update function differs from Enemy's.
The error I get is:
// Game Loop //
if (UpdateClock.GetElapsedTime() > GameLoopTimeLimit)
for (vector<Actor*>::iterator p_it = Players.begin(); p_it != Players.end(); ++p_it)
for (vector<Actor*>::iterator e_it = Enemies.begin(); e_it != Enemies.end(); ++e_it)
Render(Game, Camera, Players, Enemies);
I may not have explained the idea well, but basically a vector of pointers to Player is looped though, and for each player, each Enemy Pointer has it's Enemy Object's Update function run with the current player as an argument.
/storage/Projects/Recent/Refactored Game/src/main.cpp|156|error: request for member ‘Update’ in ‘* e_it.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-> [with _Iterator = Actor**, _Container = std::vector<Actor*>, __gnu_cxx::__normal_iterator<_Iterator, _Container>::pointer = Actor**]()’, which is of non-class type ‘Actor*’|
Any help fixing this code up would be wildly appreciated.
I read through and realized I may not have made it clear what I want to do.
I want to call the appropriate Update function, of the Enemy Object, pointed to by e_it. If anyone can help me just decipher that error code, I can work on it myself. I really don't want or expect anyone to re-write my code for me.