Reputation: 33
I'm creating diferent Child Structs with a diferent implementation of a function, starting with a base Parent function.
I want a general reference to call the function of a Child in another struct as a pointer. Then change to another child struct and call the function of the new child.
struct State{
virtual void Update(){
}
};
struct IdleState : State{
void Update (bool* var){
//some code
}
};
struct StateMachine{
State* currentState;
void Initialize(State* newState){
currentState = newState;
}
void Update(){
currentState.Update();
}
};
Upvotes: 0
Views: 47