virtual
in the base class
so that the compiler will always know whether to use the base
class version or the derived class version (see below).
private:
parts
private:
parts of the base class.
protected:
parts of the base class.
fourpart FourPartObject; fourpart *FourPartPointer; threepart *ThreePartPointer; ThreePartPointer = FourPartPointer = &FourPartObject; ThreePartPointer->ReportTheValues(); //----Calls the threepart version FourPartPointer->ReportTheValues(); //----Calls the fourpart version
ReportTheValues
is declared as virtual in
threepartclass.h, then the
above confusion does not arise.
virtual
before
the return type in their declaration, e.g.,virtual void ReportTheValues(void);
virtual
in the base class.
= 0
after the parameter list in their declaration, e.g.,virtual OnlyInBaseClass(void) = 0;