Suppose I have a base class with a method to return a state of its instance:
enum STATE {ALIVE, DEAD}
class BASE{
virtual STATE doThingsAndReturnStatus() {...};
}
Now I have my derived class which may have additional state, e.g. HALFDEAD
. It looks to me it is difficult to get the interface consistent unless for each derived class I need to add a STATE globally. (i.e. add new items into the definition of STATE
in class BASE
). My question is how to achieve this type of extending for derived class without touching on the based class or the file contains it.)
It is not necessary to restrict the discussion on "enum" only.
I found a related thread here. But it doesn't fit into my needs: