What is a virtual function?

What is a virtual function?

1 Like

Virtual function is an example of dynamic polymorphism.

Virtual function is used when we want to call the derived class function using the base class pointer. This provides new implementation of derived class method into base class. The invoking of this new function with base class’s object is done by making base class function as virtual function. This is how we can achieve Runtime Polymorphism.