C++ virtual function is a member function that is declared in the base class and redefined by a derived class. The virtual function is used to tell the compiler to perform dynamic linkage or late binding (means, the compiler determines the type of object it is having and then it binds the function call) on the function. We have to create a  pointer to the base  class, and then that pointer refers to the object of the derived class.

Virtual Function in C++

Polymorphism refers to a property by which objects belonging to a different class can respond to the same message but in various forms. When there are C++ functions with the same name in both superclass as well as a subclass, virtual functions gives programmer capability to call a member function of a different class by the same function call based upon different context.

#c++ #c++ virtual function

Virtual Function in C++ Example | C++ Virtual Function Tutorial
2.80 GEEK