小编mey*_*our的帖子

C++中的加号运算符

我读过加号运算符将其右值添加到其左值中。例如,如果我们编写x + 1;加号运算符x,在内存中查找变量并添加1到其中。

但是这个运算符不是这样工作的,因为在下面的代码中,它不会添加1到它的左值 ( x)。

int x = 4;
x + 1;// now the + operator adds 1 to x variable.
std::cout << x << std::endl;// this line must print 5 but doesn't.
Run Code Online (Sandbox Code Playgroud)

如果它不工作,就像我怎么解释,那怎么工作?

c++ operator-keyword

0
推荐指数
1
解决办法
93
查看次数

标签 统计

c++ ×1

operator-keyword ×1