Ch. 15 - Inheritance, Polymorphism, and Virtual Functions
What is polymorphism
ability to take many forms
what is base class access specification
affects how the members of the base class are inherited by the derived class
What is inheritance?
allows a new class to be based on a existing class --> new class inherits all the member variables and functions
What is a abstract base class
cannot be instantiated but other classes are derived from it
how do constructors and destructors work in base and derived classes
constructor is called before the derived class's constructor. destructors called in reverse order --> derived class's destructor called first
What is overriding base class functions
dynamically bound. only virtual functions can be overriden
Private base class access specification
private members: inaccessible protected members: private public members: private
Protected base class access specification
private members: inaccessible protected members: protected public members: protected
public base class access specification
private members: inaccessible protected members: protected public members: public
what is redefining base class functions
statically bound
what is a pure virtual function
virtual member function of a base class that must be overridden. written like this: virtual void methodName() = 0;
What is multiple inheritance
when a derived class has 2 or more base classes
what are virtual destructors
when you write a class with a destructor and that class could potentially become a base class