- Virtual function is a member function which is re-defined by a derived class and declared within a base class.
- When you refer to a derived class object using a reference or pointer to the base class, you can call a virtual function for that object and execute the derived class’s version of the function.
- It ensures that the correct function is called for an object, regardless of the type of reference used for function call.
- It is mainly used to achieve Run-time polymorphism.
- In base class functions are declared with a virtual. At run time the resolving of function call is done.
W