Question: .In C++. Design 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++. Design 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 function, define two variables a triangle and a rectangle and then call the area() function in this two varibles.
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)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
