They are mainly used to achieve Runtime polymorphism.
Functions are declared with a virtual keyword in base class.
A virtual function is a member function which is declared within a base class and is re-defined(Overriden) by a derived class. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class’s version of the function.
#VirtualFunction
#DynamicPolymorphism
#polymorphism
#PolymorphismInC++
#RunTimePolymorphism
#OOP
Негізгі бет Virtual function with Example II Polymorphism II OOP II C++
Пікірлер: 3