S01E03 Inheritance and Polymorphism

Object Oriented

OOP has three features:

  1. Encapsulation
  2. Inheritance
  3. Polymorphism


  1. C++’s default inheritance is private
  2. It’s recommended to start with public inheritance
  3. There are three modes: private, public and protected


  1. Refactoring methods based on the methods defined in the base class.
  2. Must guarantee that the method name and parameters are exactly the same

Polymorphism and Binding

  1. In C++, the default binding is static binding, which is set during the compiling time
  2. Polymorphism uses dynamic binding
  3. Inheritance + Methods Refactoring + Virtual Methods + Reference to the Parent Class/Pointer pointing to the Child Class
  4. To convert the static binding to the dynamic binding, refactor the Parent class method into a virtual method by adding “virtual” at the beginning

   Reprint policy

《S01E03 Inheritance and Polymorphism》 by Isaac Zhou is licensed under a Creative Commons Attribution 4.0 International License