Skip to content

C++ Program to Demonstrate inline Function using Call by Reference

C++ Program to Demonstrate inline Function using Call by Reference

Code:

/*C++ Program to Demonstrate inline Function using Call by Reference*/
#include<iostream.h>
#include<conio.h>

class callbyref
{
 public:
 inline void swap(int &x, int &y)
 {
 int temp;
  temp=x;
  x=y;
  y=temp;
 }
};

void main()
{
  clrscr();
  callbyref obj;
  int a=100,b=200;
  //cout<< “n Enter 2 Numbersn”;
  //cin>>  val1 >> val2;
  cout<< “n Before swap value of a & b = ” << a << “t” << b <<endl;
  obj.swap(a,b);
  cout<< ” After swap value of a & b = ” << a << “t” <<  b <<endl;
  getch();
}


Sample Output:

Comment bellow for your Query and Feedback

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!