-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvfunc5.cpp
More file actions
107 lines (106 loc) · 1.54 KB
/
Copy pathvfunc5.cpp
File metadata and controls
107 lines (106 loc) · 1.54 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
write a prorgram area of rectangle , circle , square , triangle , using pure virtual functions
*/
#include<iostream>
using namespace std;
class a
{
public:
virtual void area()=0;
virtual void display()=0;
};
class rectangle:public a
{
int a,b;
float res;
public:
rectangle(int x,int y)
{
a=x;
b=y;
}
void area()
{
res= a*b;
}
void display()
{
cout<<"area of rectangle : "<<res<<endl;
}
};
class circle:public a
{
int a;
float res;
public:
circle(int x)
{
a=x;
}
void area()
{
res= 3.14*(a*a);
}
void display()
{
cout<<"area of circle : "<<res<<endl;
}
};
class square:public a
{
int a;
float res;
public:
square(int x)
{
a=x;
}
void area()
{
res= a*a;
}
void display()
{
cout<<"area square : "<<res<<endl;
}
};
class triangle:public a
{
int a,b;
float res;
public:
triangle(int x,int y)
{
a=x;
b=y;
}
void area()
{
res= a*b;
}
void display()
{
cout<<"area of triangle : "<<res<<endl;
}
};
int main()
{
a *pointer;
rectangle r(1,2);
circle c(3);
square s(6);
triangle t(5,1);
pointer=&r;
pointer->area();
pointer->display();
pointer=&c;
pointer->area();
pointer->display();
pointer=&s;
pointer->area();
pointer->display();
pointer=&t;
pointer->area();
pointer->display();
return 0;
}