|
why is this C++code wrong? -
January 2nd, 2008
int main()
{
int x=10;
int y=20;
cout<<*(swap(x,y));
return 0;
}
int *swap(int x, static y)
{
int t=y;
y=x;
x=t;
return &y;
}
shouldn't it print 10 in the output?
when I compile it I recieve these errors and warnings:
error C2100: illegal indirection
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
warning C4042: 'y' : has bad storage class
warning C4172: returning address of local variable or temporary
|