相关疑难解决方法(0)

Weird behaviour of prefix and postfix operators

Why is the first expression allowed, but the second not:

void test()
{
   int a;

   ++a = getSomeInt();
   a++ = getSomeInt();
}
Run Code Online (Sandbox Code Playgroud)

I mean, why its forbidden for the second one to be an lvalue? The second one makes sense and the first not. In the first one we increment the variable and immediately after we gave here a new value, we lose it. That's not the case in the second expression. It makes sense to assign some value …

c++ compiler-construction standards

3
推荐指数
1
解决办法
386
查看次数

标签 统计

c++ ×1

compiler-construction ×1

standards ×1