-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_AssignmentOperater.cpp
More file actions
51 lines (39 loc) · 936 Bytes
/
3_AssignmentOperater.cpp
File metadata and controls
51 lines (39 loc) · 936 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
50
51
/*In C++ how the class data members of one object to be copied to the another object data memebers*/;
#include <iostream>
using namespace std;
class algebra
{
public:
int x;
int y;
void getData()
{
cout<<"The value of x ="<<x<<endl;
cout<<"The value of y ="<<y<<endl;
}
};
int main()
{
algebra obj1;
algebra *obj2=new algebra;
obj1.x=1;
obj1.y=2;
//MEMEBER WISE COPYING
cout<<"\t\tMEMEBER WISE COPYING :"<<endl;
obj2->x=obj1.x;
obj2->y=obj1.y;
cout<<"The values in object 1 : "<<endl;
obj1.getData();
cout<<"The values in object 2 : "<<endl;
obj2->getData();
// Aggregate WISE COPYING
cout<<"\t\tAggregate WISE COPYING :"<<endl;
(*obj2)=obj1;
cout<<"The values in object 1 : "<<endl;
obj1.getData();
cout<<"The values in object 2 : "<<endl;
obj2->getData();
delete obj2;
obj2=nullptr;
return 0;
}