The word poly means many, and morphism means several forms. Both the words are derived from Greek language. Thus, by combining these two words, a new whole word called polymorphism is created,which means variousforms.
The information pertaining to various overloaded member functions is to be given to the compiler while compiling. This is called earlybinding or staticbinding. The deciding function call at run time is called runtimeor lateor dynamicbinding. Dynamic binding permits to suspend the decision of choosing a suitable member function until run time.
Pointers to the object of a base class are type compatible with pointers to the object of a derived class. The reverse is not possible.
Virtual functions of the base class should be redefined in the derived classes. The programmer can define a virtual function in a base class, and can then use a similar function name in any derived class.
Addresses of different objects can be stored in an array to invoke the function dynamically.
In practical applications, the member function of the base class is rarely used for doing any operation; such functions are called do-nothingfunctions, dummyfunctions, or purevirtualfunctions.
All other derived classes without pure virtual functions are called concreteclasses.
Abstract classes are similar to a skeleton on which new classes are designed to assemble a well-designed class hierarchy. They are not used for object declaration.
Virtual functions can be invoked using a pointer or a reference.
If an object of a derived class is assigned to a base class object, the compiler allows it. However, it copies only the base class members of the object, and this process is known as objectslicing.
It is possible to invoke a virtual function using a constructor. The constructor makes the virtual mechanism illegal.
We have learned how to declare virtual functions. Likewise, destructors can be declared as virtual. The constructor cannot be virtual. The virtual destructors are implemented in a similar manner to virtual functions. Destructors of derived and base classes are called when a derived class object addressed by the base class pointer is deleted.
Test Your Skills
Test Your Skills Now!
This is only a practice test, it is designed to help you revise your concepts
The test contains questions, only 1 option is correct for each question
This is a timed test.
After you have finished the test, press on the 'Finish Test' button to know your score and get the correct answers