In the class Shape
, add keyword virtual
to the output()
function as follows: virtual void output();
This allows the output()
function of Shape
to be overridden by the output()
of Rectangle
and Triangle
in dynamic binding (when it's called from reference or a pointer).
That's it. No need to change anything. The main function is the same as Lab 13-2. Do not change it.
10 7 blue
10 5 black
I'm a Rectangle: location_x = 10, location_y = 7, color = blue
I'm a Triangle: location_x = 10 , location_y = 5, color = black
I'm a Rectangle: location_x = 10, location_y = 7, color = blue
I'm a Triangle: location_x = 10 , location_y = 5, color = black