Ask a Teacher



define a class to perform swap operation include 2 data members a&b &member function to input values,swap the value& display the value

class swap 
{
int a,b; 
public void swap() 
{
cout<<"Before swapping";
cout<<"Enter the no. "; 
cin>>a>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"After swapping";
cout<<"a= "<<a;
cout<<"b= "<<b; 
 }


comments powered by Disqus