There is a simple version of my code :
class Action:
{
int updateOK() {
std::cout << "" << std::endl;
return 0;
}
}
class Attack:public Action
{
int updateOK() {
std::cout << "att" << std::endl;
return 0;
}
}
class Def:public Action
{
int updateOK() {
std::cout << "DEf" << std::endl;
return 0;
}
}
namespace actions
{
const Attack light = Attack();
const Attack meduim = Attack();
const Attack heavy = Attack();
const Block block = Block();
const Block cancelBlock = Block();
const std::vector<Action> listAction = { light , meduim, heavy , block, cancelBlock };
}
Main.cpp :
for each (Action action in actions::listAction) {
action.updateOK();
}
The issue is that it always calls the parent function in the main.
I have tried virtual functions in many ways but I want to find a solution to the problem without casts.
Is it possible ?