I'm a student who got interested in computer science recently. I'm studying C++ because I am interested in embedded systems.
When I tried to test the operator /=
on my own. I want to learn about it by doing. The code that I wrote was
int a /= --b + 3;
but the compiler gave me an error message. But when I modified it to
int a = 0;
a /= --b + 3;`
it worked well. I thought it is related to l-values and r-values. Why does the 1st example with operator /=
give me an error but the 2nd example above is ok? Can I ask you for some reference to get a hint about this question?
PS: When I tested with
int t = t / (--a + 3);
it worked well too! What is the difference? Can you point me to some document about that?