<P> When a derived class inherits from a base class, it must define or override the virtual inner classes it inherited from the base class . An object of the child class may be referred to by a reference or pointer of the parent class type or the child class type . When the reference or pointer invoke the virtual inner classes, the derived class's implementation will be called if the object is of the derived class type . The type of the outer class determines the run time of the inner virtual class . </P> <P> A method with an object argument has access to the object's virtual classes . The method can use the virtual classes of its arguments to create instances and declare variables . Virtual classes of different instances are not compatible . </P> <P> For example, a base class Machine could have a virtual class Parts . Subclass Car would implement Parts differently than the subclass Bicycle, but the programmer can call any methods in the virtual inner class Parts on any class Machine object, and get the Parts implementation of that specific derived class . </P> <P> Any object of class type Machine can be accessed the same way . The programmer can ask for the number of wheels (by calling get_Wheels ()), without needing to know what kind of machine it is, how many wheels that machine has, or all the possible types of machines there are . Functions like get_Fuel_Type () can be added to the virtual class Parts by the derived class Car . </P>

When do we make a class virtual base class in c++