According to C++03 3.10/1 every expression is either an lvalue or an rvalue. When I use =
to assign a new value to a variable the variable name on the left of the assignment is an lvalue expression. And it looks like whatever I try to do with a variable it'll still use some expression.
Is there any way to manipulate a variable in C++ other than by using an expression?
The only way would be through a statement, yet not via an expression which is part of such a statement. An example would be a definition, std::string x;
. This calls the default ctor on x
. But does this count as a manipulation to you?
There aren't that many other statements, actually. Loop control statements cannot change objects themselves other than via side effects of the loop control expressions. goto
, break
and continue
can't do it at all. throw
is an expression and catch()
can't change anything, so that pair is also irrelevant. I don't think there's any other non-expression-statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With