13784 - EE2310_Lab_13_3   

Description

Virtual Functions & Dynamic Binding

What You Need to Do

  1. 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).

  2. That's it. No need to change anything. The main function is the same as Lab 13-2. Do not change it.

Input

10 7 blue
10 5 black

Output

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

Sample Input  Download

Sample Output  Download

Tags




Discuss