I'm doing a parsser for a class call virtual_machine, I'm trying to build a vectors of function for it, but some of those function on vm takes arguments (different numbers/types of arguments) can i still put those in my vector of fuction since they where only void (*f)();
here's the code
class Virtual_Machine {
public:
/***/
void clear();
void pop();
void clear();
void assert(std::string const &value);
void push(eOperandType const &e, std::string const &str);
/***/
}
class Parser {
public:
/***/
void prepare();
void add_func_no_arg(void (Virtual_Machine::*f)(), std::string comand);
private:
Virtual_Machine vm;
std::vector<std::string> command_no_arg;
std::vector<void (Virtual_Machine::*)()> func_no_arg;
/***/
};
void Parser::add_func_no_arg(void (Virtual_Machine::*f)(), std::string comand)
{
command_no_arg.push_back(comand);
func_no_arg.push_back(f);
}
void Parser::prepare()
{
add_func_no_arg(&Virtual_Machine::dump,"dump");
add_func_no_arg(&Virtual_Machine::pop,"pop");
add_func_no_arg(&Virtual_Machine::clear,"clear");
}
void Parser::use_exemple()
{
// dump :
(vm.*(func_no_arg[0]))();
}
this is ok but now I will to kwon if it's possible to add push() and assert() toi my vector of funtions , what do i need to do ? i was thinking maybe templat but i realy don't see how