CS174: Module 12: C++ Inheritance: Basics

Developed by Professor Tralie and Professor Mongan.


Please watch the video below, and click the next button once you have finished

Notes

  • The syntax class Child: public Parent is the basic syntax for inheriting the class Parent in the class Child
  • A constructor Child(args): Parent(args) is the syntax for calling a parent class constructor while defining the child constructor.
  • protected works the same way as it does in Java, we just need to define all protected variables in their own protected: block
  • Methods can be overridden, and the method versions of the parent class can be called with the Parent::method syntax