pls expalin

#include<iostream.h>
int maxref(int &a, int &b)
{
if(a>b)
return a;
else
return b;
}
void main()
{
int x=20, y=30, max=0;
maxref(x,y)=-1;
cout<<"\n Value of x is"<<x;
cout
cout<<"\n value of y is:"<<y;
getch();
}


output

value of x is : 20
value of y is : -1


How this output displayed. why value of y is assigned =-1


Last edited on
This code does not compile in any compiler. What compiler are you using? It must be a few decades out of date.

<iostream.h> is deprecated, there exists only <iostream>

In C++ main always returns an int, not void.

The return value of maxref is not a reference so you cannot assign to it like you do in this program.

There is an extraneous cout in your program, this surely will not compile.
Last edited on
turbo c++
Topic archived. No new replies allowed.