Sometimes we may have a derived class with two base classes, which is derived from two other base classes. In this situation, a problem may arise of ambiguous. Using virtual class we can removes the ambiguous data and avoids redundancy.
When we use the same function name in both the base and derived classes than virtual function is use, it is declared in base class. When a function is made as virtual CPP determines which function to use at run time based on the type of object pointed by the base pointer.
Rules for Virtual Functions:
Pure Virtual Function:
Virtual Functions are not used for any purpose other than providing declaration. A do nothing functions is a pure virtual function.
virtual void display( )=0;