What is virtual function and why it is used? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is virtual function and why it is used?

In polymorphism module of C++ tutorial (solo learn) I could not understand what was meant by line "Every derived class will override the attack() function and have a separate implementation" https://www.sololearn.com/learn/CPlusPlus/1911/ Can anyone explain? Also please tell What is virtual function and why it is used?

18th Jun 2019, 3:25 PM
Swati Tripathi
Swati Tripathi - avatar
1 Answer