How to assign different classes objects in game? c++ newbie

Hi, I’m new to C++
In my Game.h i have strongly-typed variable Actor *actor;. How can I assign to my actor another Actor2Class or Actor3Class object for other levels? In my Game.cpp i will call same functions actor->function();

If you mean that every actor are instances of the same class you simple should have to do:

delete actor;
actor = anotheractor;

no, different classes, but they have same functions to call. The problem is that if I have actor type ActorClass I cant assign to actor DifferentActorClass, and it seems to me to be wrong to have different game classes with same code, but different actor types

@fataldevelop
You should probably read about polymorphism a bit :smile:
Here:
http://www.cplusplus.com/doc/tutorial/polymorphism/
Or here:
http://www.tutorialspoint.com/cplusplus/cpp_polymorphism.htm
Or just type in google :stuck_out_tongue:

1 Like

Many thanks, exactly what i needed to learn)