forked from Vishal-Aggarwal0305/DSA-CODE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConstructorADD.cpp
65 lines (62 loc) · 1.34 KB
/
ConstructorADD.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;
#define pi 3.14
class con
{
public:
int a, b, c;
float d;
con(int x, int y, int z, float w) //parametrised
{
a = x;
b = y;
c = z;
d = w;
}
int sum()
{
return (a + b);
}
int cube()
{
return c * c * c;
}
float area()
{
return pi * d * d;
}
con(con ©)
{
a = copy.a;
b = copy.b;
c = copy.c;
d = copy.d;
}
void display()
{
cout << "the sum is=" << sum() << endl;
cout << "the cube is=" << cube() << endl;
cout << "the cube is=" << area() << endl;
}
};
int main()
{
int a, b, c;
float d;
cout << "Enter 2 numbers to add:" << endl;
cin >> a >> b;
cout << "Enter number to find cube: " << endl;
cin >> c;
cout << "Enter number to find Area of circle: " << endl;
cin >> d;
con obj(a, b, c, d);
con obj2 = obj;
cout << "Normal constructor : " << endl;
obj.display();
cout << "-------------------------------------------------------------------------------" << endl;
cout << "Copy constructor : " << endl;
obj2.display();
// cout << "the sum is=" << obj.sum() << endl;
// cout << "the cube is=" << obj.cube() << endl;
// cout << "the cube is=" << obj.area() << endl;
}