-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht6.cpp
More file actions
52 lines (41 loc) · 721 Bytes
/
Copy patht6.cpp
File metadata and controls
52 lines (41 loc) · 721 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
52
/*
properties of friend
1. not in scope of class
2. can be invoved without the help of object
3.usually contains the objects as arguments
4. can be declared inside public or private
*/
#include<iostream>
using namespace std;
class complex{
int a,b;
public:
void read(int x,int y)
{
a=x;
b=y;
}
void print()
{
cout<<"complex no are "<< a<<" + "<<b<<" i "<<endl;
}
friend complex add(complex c1,complex c2);
};
complex add(complex c1,complex c2)
{
complex c3;
c3.a=c1.a+c2.a;
c3.b=c1.b+c2.b;
return c3;
}
int main()
{
complex c1,c2,c3;
c1.read(2,4);
c1.print();
c2.read(3,7);
c2.print();
c3 =add(c1,c2);
c3.print();
return 0;
}