小编Ksh*_*mal的帖子

有人可以解释速记分配运算符的实际工作方式吗?

#include <iostream>
using namespace std;
int main()
{   
    int x=2,a=3,b=2;
    x*=a/b;
    cout<<x<<" ";
    x=2;
    x=x*a/b;
    cout<<x;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我得到的输出为:2 3在我看来x * = a / b; 和x = x * a / b; 意思是一样的。有人可以解释这种行为吗?

c++ shorthand assignment-operator

4
推荐指数
2
解决办法
97
查看次数

标签 统计

assignment-operator ×1

c++ ×1

shorthand ×1