Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- using namespace std;
- class Shape
- {
- public:
- double length,breadth,height,base;
- void get_data()
- {
- //double length,breadth,height,base;
- cout<<"Enter the length of the Rectangle: ";
- cin>>length;
- cout<<"Enter the breadth of the Rectangle: ";
- cin>>breadth;
- cout<<"Enter the height of the Triangle: ";
- cin>>height;
- cout<<"Enter the base of the Triangle: ";
- cin>>base;
- }
- };
- class Rectangle : public Shape
- {
- public:
- void area_of_rac()
- {
- double area = length*breadth;
- cout<<"The Rectangle area: "<<area<<endl;
- }
- };
- class Triangle : public Shape
- {
- public:
- void area_of_tri()
- {
- double area = 0.5*height*base;
- cout<<"The Triangle area: "<<area<<endl;
- }
- };
- int main()
- {
- Shape obj;
- obj.get_data();
- Rectangle obj1;
- obj1.area_of_rac();
- Triangle obj2;
- obj2.area_of_tri();
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement