C++ Inheritance & Polymorphism: Pure Virtual Functions & Abstract Classes
Pure virtual functions and interfaces are very powerful tools in object-oriented programming and interface-driven programming is a great way of splitting up work across different developers on a large project. You will start this course by considering why your destructors should be marked as virtual in the base class if you have an inheritance hierarchy. You’ll see the harmful effects of not using virtual destructors in an inheritance hierarchy and the problems with object slicing. You will also learn why it is preferable to have variables of reference types to the base class rather than the value types. You will then move to some finer points of working with virtual methods such as the inadvisability of using default parameters because these are statically bound. Finally you will master the syntax and semantics of pure virtual functions and learn how a class that contains even one pure virtual function becomes an abstract class that cannot be instantiated directly.