-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut29Typical.cpp
65 lines (57 loc) · 1.12 KB
/
tut29Typical.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
64
65
#include <iostream>
using namespace std;
void name()
{
cout << 'Author: Varun Gupta' << endl;
}
//Swapping of two numbers using friend function.
class Queen;
class Jack
{
int a;
friend int Reverse(Jack &, Queen &);
public:
Jack()
{
cout<<"Enter the first value :"<<endl;
cin>>a;
}
void enoutdata()
{
cout << "The first entered value before swapping is :" << a<< endl;
}
};
class Queen
{
int b;
public:
friend int Reverse(Jack &, Queen &);
Queen()
{
cout<<"Enter the second value :"<<endl;
cin>>b;
}
void Sec()
{
cout << "The second value before swapping is :" << b << endl;
}
};
int Reverse(Jack &a1, Queen &a2)
{
cout<<"The values are :"<<a1.a<<"\t"<<a2.b<<endl;
int temp = a1.a;
a1.a = a2.b;
a2.b = temp;
cout << "After swapping :" << a1.a << "\t" << a2.b << endl;
return 0;
}
int main()
{
name();
Jack j1;
// j1.enoutdata();
Queen q1;
// q1.Sec();
cout<< Reverse(j1, q1) << endl;
return 0;
}