#include <iostream.h>
#include <conio.h>
class swaping
{
int a;
public :
void getdata(void);
friend void swap(swaping &,swaping &);
void display(void);
};
void swaping :: getdata(void)
{
cout<<"\n\nEnter any Integer :-";
cin>>a;
}
void swap(swaping &o1,swaping &o2)
{
int temp;
temp = o1.a;
o1.a = o2.a;
o2.a = temp;
}
void swaping :: display(void)
{
cout<<a<<endl;
}
void main()
{
clrscr();
swaping o1,o2;
cout<<"Before Swaping\n";
o1.getdata();
o2.getdata();
swap(o1,o2);
cout<<"\n\nAfter Swaping\n";
o1.display();
o2.display();
getch();
}
#include <conio.h>
class swaping
{
int a;
public :
void getdata(void);
friend void swap(swaping &,swaping &);
void display(void);
};
void swaping :: getdata(void)
{
cout<<"\n\nEnter any Integer :-";
cin>>a;
}
void swap(swaping &o1,swaping &o2)
{
int temp;
temp = o1.a;
o1.a = o2.a;
o2.a = temp;
}
void swaping :: display(void)
{
cout<<a<<endl;
}
void main()
{
clrscr();
swaping o1,o2;
cout<<"Before Swaping\n";
o1.getdata();
o2.getdata();
swap(o1,o2);
cout<<"\n\nAfter Swaping\n";
o1.display();
o2.display();
getch();
}
0 comments:
Post a Comment