- What is polymorphism?
- What two types of functions are not inherited by a derived class?
- What does
protectedaccess imply for a class field or function? - How do we initialize the private fields that are inherited from a Base class in a constructor of a Derived class?
- What is dynamic binding and how do we enable it?
-
What is the output of the below code? What if we remove “virtual” from compute() in the BaseClass?
class BaseClass { public: virtual void compute() { std::cout << "base "; } }; class ChildClass : public BaseClass { public: virtual void compute() { std::cout << "child "; } }; int main() { BaseClass b; b.compute(); ChildClass c; c.compute(); BaseClass *p; p = &b; p->compute(); p = &c; // allowed because each ChildClass object "IS-A" BaseClass object p->compute(); } - Can a child class have multiple parents?