Hi everyone, i have an exercise using virtual function. I understand virtual function when use it with pointer. But i dont understand what this exercise want me to do.
Here it is:
-------------------------------------------------------------------------------
Some animals' speed
[Table]
-------------------
Human: 30 km/h
Leopard: 100 km/h
Lion: 70 km/h
------------------
Write a program to compare 2 animals speed, for instance, Human-Leopard, .....
Now, add horse (70 km/h) into that box, how the program changes?
-------------------------------------------------------------------------------
I know i should create a
1 2 3 4
class Animal,
then class Human: public Animal,
class Leopard : public Animal,
and class Lion : public Animal.