Original Post
Hi there! I have a problem concerning inheritance or better said with overwriting inherited functions: I got a base class Entity, which supplies a function Update(float t). Furthermore I have a class Scene that keeps a std::vector< Entity * > and is meant to call that Update-function every frame. These classes are compiled into a DLL. Now the idea is that I can use this DLL in my main project, implement some classes that inherit from Entity, define new Update-functions there to get custom behaviour, and throw these derived classes at the std::vector< Entity * > in my scene, so the scene updates the entities automatically. However if I do something like this:
class Player : public Entity
{
...
void Update(float t)
{
// do my update stuff here
}
}
the only function that gets called by my Scene class is the Update-function from the base class Entity, not the one of the derived class Player like I´d expected. So my idea for a solution would be something like using type-IDs (perhaps int´s or strings) to identify which derived class that Entity* actually is and call the derived function explicitely, but that would be rather ugly I think and as far as my understanding of inheritance goes that shouldn´t be needed at all. Any help appreciated. Thx for reading.