// Return by refernce
#include <iostream.h>
#include <conio.h>
void main()
{
int a, b;
int &refa = a;
int &refb = b;
clrscr();
int & max( int &, int &);
cout << "Enter value a : ";
cin >> a;
cout << "Enter value b : ";
cin >> b;
cout << "Before calling function : " << endl;
cout << "A = " << a << endl;
cout << "B = " << b << endl;
max(refa, refb) = -1;
cout << "After calling function :" << endl;
cout << "A = " << a << endl;
cout << "B = " << b << endl;
getch();
}
int & max( int &ref1, int &ref2)
{
if(ref1 > ref2)
{
return ref1;
}
else
{
return ref2;
}
}
Comments
Post a Comment