Sunday 25 August 2013


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 Numbers\n";
  //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

Related Posts :



0 comments:

Confused? Feel free to ask

Post a Comment