-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCODE25.cpp
More file actions
49 lines (42 loc) · 972 Bytes
/
CODE25.cpp
File metadata and controls
49 lines (42 loc) · 972 Bytes
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
#include <iostream> //LEARN COPY CONSTRUCTOR
using namespace std;
class Const
{
int a;
int b;
public:
Const() //<-----------DEFAULT CONSTRUCTOR for a1
{
a = 1;
b = 2;
}
Const(int num,int num_2) //<-------CONSTRUCTOR OVER LOADING for b1
{
a = num;
b = num_2;
}
Const(Const &obj) //<-----------COPY CONSTRUCTOR for c1
{
a = obj.a;
b= obj.b;
}
void Getdata(void) //<------A FUNCTION IN WHICH WE WE ADD OTHER OBJECT DATA TO TO OTHER OBJECT
{
cout << "this is your " << a<<endl;
cout << "this is your " << b<<endl;
}
};
int main()
{
Const a1, b1(23,24);
cout << "this is a1" << endl;
a1.Getdata();
cout << endl;
cout << "this is b1" << endl;
b1.Getdata();
cout << endl;
cout << "this is c1" << endl;
Const c1(b1);
c1.Getdata();
return 0;
}