//BCA Support
//www.bcasupport.xyz
#include <iostream.h>
#include <conio.h>
class class1
{
int no;
friend void swap();
};
class class2
{
int no;
friend void swap();
};
//Function Declaration
void swap();
void main()
{
clrscr();
swap();
getch();
}
void swap()
{
class1 obj1;
obj1.no=10;
class2 obj2;
obj2.no=20;
cout<<"\nBefore swapping :\nNumber 1 : "<<obj1.no;
cout<<"\nNumber 2 : "<<obj2.no<<endl;
int temp=obj1.no;
obj1.no=obj2.no;
obj2.no=temp;
cout<<"\nAfter swapping :\nNumber 1 : "<<obj1.no;
cout<<"\nNumber 2 : "<<obj2.no;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.