I am a bit puzzled about why one can savely write
getValue() = 5;
in the below. The left hand side is a function. Why can we set that to 5?
int& getValue()
{
static int& value = 10;
return value;
}
int main (void)
{
std::cout << getValue()<< std::endl;
getValue() = 5;
std::cout << getValue() << std::endl;
}
This will return:
10
5