-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathop+Overload.cpp
63 lines (57 loc) · 1.27 KB
/
op+Overload.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
#include<iostream>
using namespace std;
class operatorOverload
{
public:
int a,b;
public:
int setdata(int,int);
/* int setdata(int x,int y)
{
a=x;
b=y;
}*/
// void display();
// operatorOverload operator+(operatorOverlaod&); //declaration
operatorOverload operator+( operatorOverload c)
{
operatorOverload temp;
temp.a=a+c.a;
temp.b=b+c.b;
return temp;
}
void display()
{
cout<<"result:"<<a<<endl<<b<<endl;
// cout<<"operator:"<<b<<endl<<b<<endl;
}
operatorOverload operator -(operatorOverload c)
{
operatorOverload temp;
temp.a=a-c.a;
temp.b=b-c.b;
return temp;
}
};
int operatorOverload::setdata(int x,int y)
{
a=x;
b=y;
}
/* operatorOverload::operatorOverload operator+( operatorOverload &c)
{
operatorOverload temp;
temp.a=a+c.a;
temp.b=b+c.b;
return temp;
} */
int main()
{
operatorOverload p4,p1,p2,p3;
p1.setdata(3,4);
p2.setdata(6,7);
p3=p1+p2;
p4=p2-p1;
p3.display();
p4.display();
}