problem 5.10(example)
#include<bits/stdc++.h>
using namespace std;
class xyz;
class abc
{
public:
int a;
public :
void get(int x)
{
a=x;
}
void display()
{
cout<<"AA : "<<a<<endl;
}
friend void add(xyz,abc);
};
class xyz
{
public:
int b;
public :
void get(int x)
{
b=x;
}
void display1()
{
cout<<"XX : "<<b<<endl;
}
void friend addd(xyz &aa,abc &bb);
};
void addd(xyz &aa,abc &bb)
{
int temp;
temp=aa.b;
aa.b=bb.a;
bb.a=temp;
}
int main()
{
int p,q;
ifstream in;
in.open("input.txt");
in>>p>>q;
abc cc;
xyz xx;
cc.get(p);
xx.get(q);
cc.display();
xx.display1();
addd(xx,cc);
cc.display();
xx.display1();
return 0;
}
0 Comments