What is a virtual function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is a virtual function

24th Nov 2016, 4:11 AM
Ankit Yadav
Ankit Yadav - avatar
2 Answers
+ 1
In object-oriented programming, in languages such as C++, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated. This concept is an important part of the (runtime) polymorphismportion of object-oriented programming (OOP). -wikipedia
24th Nov 2016, 5:25 AM
Anil Krishna Raj
Anil Krishna Raj - avatar
0
A virtual function is a member function that you expect to be redefined in derived classes. 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.
24th Nov 2016, 6:36 AM
Akwin Lopez
Akwin Lopez - avatar