class classname: access-label base-class
Ordinarily, derived classes redefine the virtual functions that they inherit, although they are not requried
to do so. If a derived class does not redefine a virtual, then the version it uses is the one defined in its
base class.
With one exception, the declaration (Section 7.4, p. 251)of a virtual function in the derived class must exactly match the way the function is defined in the base. That exception applies to virtuals that return a reference (or pointer) to a type that is itself a base class. A virtual function in a derived class can return a reference (or pointer) to a class that is publicly derived from the type returned by the baseclass function.
Note:Once a function is declared as virtual in a base class it remains virtual; nothing the derived classes do can change the fact that the function is virtual. When a derived class redefines a virtual, it may use the virtual keyword, but it is not required to do so.
A derived object consists of multiple parts: the (nonstatic)members defined in the derived class itself
plus the subobjects made up of the (nonstatic)members of its base class.
A class must be defined before it can be used as a base class. Had we declared, but not defined, Item_base, we could not use it as our base class:
class Item_base; // declared but not defined
// error: Item_base must be defined
class Bulk_item : public Item_base { ... };
If we need to declare (but not yet define) a derived class, the declaration contains the class name but does not include its derivation list. For example, the following forward declaration of Bulk_itemresults in a compile-time error:
// error: a forward declaration must not include the derivation list
class Bulk_item : public Item_base;
The correct forward declarations are:
// forward declarations of both derived and nonderived class
class Bulk_item;
class Item_base;