#include <iostream>
using namespace std;
class BB;
class AA
{
int a1;
public:
void getdata(int l)
{
a1=l;
}
void display()
{
cout<<"the value of a is"<<a1<<endl;
}
friend void swap(AA &a,BB &b);
};
class BB
{
int b1;
public:
void getdata(int m)
{
b1=m;
}
void display()
{
cout<<"the value of b is"<<b1<<endl;
}
friend void swap(AA &a,BB &b);
};
void swap(AA &a,BB &b)
{
int temp;
temp=a.a1;
a.a1=b.b1;
b.b1=temp;
}
int main()
{
AA a;
BB b;
a.getdata(10);
b.getdata(20);
a.display();
b.display();
swap(a,b);
a.display();
b.display();
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: