#include <iostream>
using namespace std;
class Number
{
int num;
public:
Number()
{
cout<<"Enter number: ";
cin>>num;
}
void display()
{
cout<<num<<' ';
}
friend void Swap(Number&, Number&);
};
void Swap(Number& obj1,Number& obj2)
{
int temp=obj1.num;
obj1.num=obj2.num;
obj2.num=temp;
}
int main()
{
Number obj1,obj2;
cout<<"\nBefore swap :";
obj1.display();
obj2.display();
Swap(obj1,obj2);
cout<<"\nAfter swap :";
obj1.display();
obj2.display();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgTnVtYmVyCnsKICAgIGludCBudW07CiAgICBwdWJsaWM6CiAgICBOdW1iZXIoKQogICAgewogICAgICAgIGNvdXQ8PCJFbnRlciBudW1iZXI6ICI7CiAgICAgICAgY2luPj5udW07CiAgICB9CiAgICB2b2lkIGRpc3BsYXkoKQogICAgewogICAgICAgIGNvdXQ8PG51bTw8JyAnOwogICAgfQogICAgZnJpZW5kIHZvaWQgU3dhcChOdW1iZXImLCBOdW1iZXImKTsKfTsKCnZvaWQgU3dhcChOdW1iZXImIG9iajEsTnVtYmVyJiBvYmoyKQp7CiAgICBpbnQgdGVtcD1vYmoxLm51bTsKICAgIG9iajEubnVtPW9iajIubnVtOwogICAgb2JqMi5udW09dGVtcDsKfQoKaW50IG1haW4oKQp7CiAgICBOdW1iZXIgb2JqMSxvYmoyOwogICAgY291dDw8IlxuQmVmb3JlIHN3YXAgOiI7CiAgICBvYmoxLmRpc3BsYXkoKTsKICAgIG9iajIuZGlzcGxheSgpOwoKICAgIFN3YXAob2JqMSxvYmoyKTsKICAgIGNvdXQ8PCJcbkFmdGVyIHN3YXAgOiI7CiAgICBvYmoxLmRpc3BsYXkoKTsKICAgIG9iajIuZGlzcGxheSgpOwoKICAgIHJldHVybiAwOwp9Cg==