Shape Class


Write a program that defines a shape class with a constructor that gives value to width and height. The 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 Test Case 1 Input (stdin) 5 6 Expected Output Rectangle area=30 Triangle area=15 Test Case 2 Input (stdin) 2 10 Expected Output Rectangle area=20 Triangle area=10

Program :

#include <iostream>

using namespace std;

int main()


int a,b,c,d;




  cout<<"Rectangle area="<<c;

  cout<<"\nTriangle area="<<d;

return 0;