Consider the following code:
#include <iostream>
using namespace std;
class X
{
int i;
public:
X(int ii = 0);
};
X::X(int ii) { i = ii; }
int a;
X f1() { return X(); }
int f2() { return a; }
int main() {
f1() = X(1);
f2() = 3;
}
If you try to run it, you get
error: lvalue required as left operand of assignment
on line 17, therefore
f1()
is considered a lvalue, while
f2()
is not. An explanation would be of great help of how things work would be of great help.