Question: In C++ Write a program that defines a shape class with a constructor that gives value to width and height. Then define two sub-classes triangle

In C++
In C++ Write a program that defines a shape class with a

Write a program that defines a shape class with a constructor that gives value to width and height. Then define two sub-classes triangle and rectangle, that calculate the area of the shape area (). In the main, define two variables a triangle and a rectangle and then call the area() function in this two variables. Area of a triangle is calculated as: height * base / 2 (in this case the base is width) Area of a rectangle is calculated as: height * width (or length * width) You do NOT have do ask for user input.... Submit your .cpp file TEST DATA: For an triangle with a base of 2 and a height of 5 the area would be 5 For a rectangle with a base (length) of 5 and a base of 3 the area would be 15

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!