#include <iostream>
using namespace std;
class Rectangle{
public:
double height;
double width;
double Rect(double height, double width)
{
return height*width;
}
};
class Triangle: public Rectangle{
public:
double trig(double height, double width)
{
return height*width*0.5;
}
};
int main()
{
Rectangle Rec;
Triangle Tri;
Rec.height=8;
Rec.width=7;
Tri.height=8;
Tri.width=7;
cout<<Rec.Rect(Rec.height,Rec.width)<<endl;
cout<<Rec.Rect(6,5)<<endl;
cout<<Tri.trig(Tri.height,Tri.width)<<endl;
cout<<Tri.trig(6,5)<<endl;
system("pause");
return 0;
}
The output is given below:
56
30
28
15
0 comments:
Post a Comment