Hello,
I have a hierarchy of Actions (NonMovingActions and MovinActions each with sub-hierarchies). Actions class has an abstract function.
Now I need to store all actions into a single vector:Code:class Action { public: Action(Agent& agent, ...):agent(agent),..{} virtual ~Action(void); virtual bool run()=0; ... }
It appears that C++ does not allow this (in Java it was possible). Compiler objects that Action class is abstract (and cannot be instantiated?!)Code:class Agent { public: Agent(World& world); virtual ~Agent(void); ... vector<Action> actions; unsigned int actionIterator; }
1- May I know what do I not understand here? We cannot refer to sub-class instances with a reference of parent class type?Code:error C2259: 'Action' : cannot instantiate abstract class
2- Should I use vector of pointers instead or what?
I appreciate your time and help.
Regards,
Mac




Reply With Quote
