-
Notifications
You must be signed in to change notification settings - Fork 0
/
tut13.cpp
46 lines (39 loc) · 845 Bytes
/
tut13.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
#include <iostream>
using namespace std;
// Forward Declaration
class Complex; // <-- we are declaring here to have compiler know that Employee have Complex and Complex will come in next lines of code
class Employee
{
int add(int a, int b)
{
return a + b;
}
int diff(Complex, Complex); // <-- friend function from Complex
};
class Complex
{
int a, b;
// making a friend for Employee class . this is for individual functions
// friend int Employee ::diff(Complex o1, Complex o2);
// full class friend
friend class Employee;
public:
void add(int v1, int v2)
{
a = v1;
b = v2;
}
void printNumbers(void)
{
cout << a << " " << b;
}
};
int Employee ::diff(Complex o1, Complex o2)
{
int a = o1.a - o2.a;
return a;
}
int main()
{
return 0;
}