-
Notifications
You must be signed in to change notification settings - Fork 0
/
oopmexp10.cpp
54 lines (41 loc) · 929 Bytes
/
oopmexp10.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<iostream>
using namespace std;
class shape //Here Shape class is an abstract class
{
public :
virtual void getarea()=0;
void setwidth();
void getwidth();
protected:
int width,height;
};
class rectangle:public shape
{
public:
void getarea()
{
cout<<"\nEnter the height/length of rectangle : ";cin>>height;
cout<<"Enter the width of rectangle : ";cin>>width;
int area=height*width;
cout<<"The area of rectangle is : "<<area<<"\n";
}
};
class triangle:public shape
{
public:
void getarea()
{
cout<<"\nEnter the height of triangle : ";cin>>height;
cout<<"Enter the base/width of triangle : ";cin>>width;
int area=0.5*width*height;
cout<<"The area of triangle is : "<<area;
}
};
int main()
{
cout<<"\n -- Abstract Class Implementation by Yash Lade -- \n";
rectangle r;
triangle t;
r.getarea();
t.getarea();
}