i want to implement i function member of a class in my main() to use functions from there.
I have this class:
class CMD{
public:
CMD();
~CMD();
virtual void execute();
};
I want to implement the execute() function in my main() to pass the resulting class to a function.
I tried this:
main(){
//....
class : public CMD {
public:
void execute(){
next(); //This function is declared in the scope of main()
}
} cmd1;
otherFunction(&cmd1);
}
The otherFunction() function would then do something like this:
void otherFunction(CMD* cmd){
cmd->execute();
}
What ever i try it fails. I'm coming from C# and Java and i can do such stuff there. Is that even possible in C++?
During compining i get the following error:
undefined reference to `vtable for CMD'