Oh Elysia is correct. How in the world did I miss that? Sorry.
If you run this code, you will see what Elysia says:
A& f(A& x)
{
return x;
}
Type: Posts; User: std10093
Oh Elysia is correct. How in the world did I miss that? Sorry.
If you run this code, you will see what Elysia says:
A& f(A& x)
{
return x;
}
If I understand correct, you mean this:
int main()
{
A a;
A c;
c = a;
return 0;
}
But, imagine that when the function gets called, the object comes from main and gets assigned to the argument of the function, thus we can imagine it as an assignment in that case, which of course...
You did that:
A b= f(a);
So, when f(a) was called, what happened to a? Moreover, look at the definition of the function named "f()". The argument is neither a reference nor a pointer. So, we...
Run the code with this function: (notice the ref)
A f(A& x)
{
return x;
}
Can you tell the difference? :)