-
Notifications
You must be signed in to change notification settings - Fork 0
/
PureVirtual.cpp
65 lines (56 loc) · 1.27 KB
/
PureVirtual.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
55
56
57
58
59
60
61
62
63
64
65
#include<iostream>
using namespace std;
class Circle
{
public:
float PI;
float Radius;
Circle()
{
PI = 3.14;
Radius = 0.0;
}
Circle(float A, float B)
{
PI = A;
Radius = B;
}
void Display()
{
cout<<"Value of Radius is : "<<Radius<<"\n";
}
virtual float Area() = 0; //abstract method
virtual float Circumference() = 0; //abstract method
};
class Marvellous : public Circle
{
public:
Marvellous() : Circle()
{
}
Marvellous(float X , float Y) : Circle(X,Y)
{
}
float Area() //concrete method
{
float Ans = PI * Radius * Radius;
return Ans;
}
float Circumference() //concrete method
{
float Ans = 0.0;
Ans = 2 * PI * Radius;
return Ans;
}
};
int main()
{
Marvellous mobj1;
Marvellous mobj2(3.14,10.89);
float fret = 0.0;
fret = mobj2.Area();
cout<<"Area is :"<<fret<<"\n";
fret = mobj2.Circumference();
cout<<"Circumference is :"<<fret<<'\n';
return 0;
}