Day 32 Recap Questions
  1. What is polymorphism?
  2. What two types of functions are not inherited by a derived class?
  3. What does protected access imply for a class field or function?
  4. How do we initialize the private fields that are inherited from a Base class in a constructor of a Derived class?
  5. What is dynamic binding and how do we enable it?
  6. 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();
    }
    
  7. Can a child class have multiple parents?