Suppose I have the class
class BaseClass { public: BaseClass(); ~BaseClass(); void runAllMethods(); };
and the sub class
class SubClass : public BaseClass { public: SubClass(); ~SubClass(); // arbitrary methods void method1(); void method2(); ... };
Suppose I then create the object
SubClass myObject = SubClass();
How do I write runAllMethods()
in BaseClass
so that it can run all methods of itself, including the methods defined in SubClass
(e.g. methods1()
, method2()
, etc.)? In other words, how do I get a superclass to access the methods in a subclass without knowing the names of the subclass' methods?