Why cant I used a function returning a pointer as a lvalue?
For example this one works
int* function()
{
int* x;
return x;
}
int main()
{
int* x = function();
x = new int(9);
}
but not this
int* function()
{
int* x;
return x;
}
int main()
{
int* x;
function() = x;
}
While I can use a pointer variable as a lvalue, why can't I use a function returning a pointer as a lvalue?
Also, when the function returns a refernce, instead of a pointer, then it becomes a valid lvalue.