The value of l can be considered as a named value that exists for its use, for example, a variable. The rvalue value is not saved after its use, as a rule, the result of a function call or what we often call simply โvalueโ.
You can save the rvalue to an lvalue ( int i = 2 + 3 ), but you cannot assign an lvalue to an rvalue. What is your problem there
The compiler throws an error because you have rvalue userInput.size() and you treat it as if it were an lvalue, trying to assign a value to it.
userInput.size() = stringSize
A simple example would be
int n = 1; 3 = n;
For obvious reasons, you can't just change what 3. In your example, your function just returns an integer value ... so why should you change this? So you get an error message
source share