- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfriendoverload.cpp
More file actions
Latest commit
35 lines (32 loc) · 518 Bytes
/
Copy pathfriendoverload.cpp
File metadata and controls
35 lines (32 loc) · 518 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
#include<iostream>
usingnamespacestd;
classa{
int x;
int y;
public:
voidread(){
cout<<"Enter the number in x :";
cin>>x;
cout<<"Enter the number in y :";
cin>>y;
}
voiddisplay(){
cout<<"the number in x :"<<x;
cout<<"the number in x :"<<y;
}
friend a operator+(a,a);
};
a operator+(a o1 , a o2){
a temp;
temp.x = o1.x + o2.x;
temp.y = o1.y + o2.y;
return temp ;
}
intmain(){
a ob1,ob2,ob3;
ob1.read();
ob2.read();
ob3 = ob1 + ob2;
ob3.display();
return0 ;
}