+ 6
Why use virtual member function
2 Answers
+ 1
Supose I have a class called Hero with an attack function and i want that all my derived classes from hero implement this function different for example the attack of a ranged hero must be different from the attack of a melee hero , thats why we use the keyword "virtual" couse it allow subclasses to make different implementation of the same function (function attack on the example) deppending on what we need.
+ 5
thanks