Write a function using reference variable as argument to swap the values of pair of integers
Answers
Answered by
0
#include<iostream.h>
#include<conio.h>
class abc
{
private:
int t;
public:
void swap(int *a, int *b)
{
t=*a;
*a=*b;
*b=t;
}
};
void main()
{
int a,b;
clrscr();
abc sa;
cout<<"Enter the values of A: ";
cin>>a;
cout<<"Enter the values of B: ";
cin>>b;
sa.swap(&a,&b);
cout<<"\nValues of A is: "<<a;
cout<<"\nValues of B is: "<<b;
getch();
}
Similar questions