I want to write a program that supports several types of commands.
In order to make it generic and easy to extend for later new commands, i want to write a class for each command (with its own handling), and call the base ‘command’ class with the handler function.
I know that in Java there is the class class to help with such a thing – to decide ‘on the flow’ the type of the class it is dealing.
Does cpp has a similar mechanism? If so, what is it and how do i use it?
If not, what can i do in order to keep it easily extended?
Thanks a lot.
You could implement a Command class with a pure virtual method.
http://www.exforsys.com/tutorials/c-plus-plus/c-pure-virtual-function-and-base-class.html