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 Parentis the basic syntax for inheriting the classParentin the classChild - A constructor
Child(args): Parent(args)is the syntax for calling a parent class constructor while defining the child constructor. protectedworks the same way as it does in Java, we just need to define all protected variables in their ownprotected:block- Methods can be overridden, and the method versions of the parent class can be called with the
Parent::methodsyntax