class Y
{
Y(X);
Y operator+(X);
operator int();
friend X operator*(X,Y);
}
上面的定义简写了。
想问,如果X x, Y y, int a;
ret=x+y+2; 这句是先执行x+y还是y+2
...全文
12311打赏收藏
C++运算的结合顺序是什么
比如说定义了这样的类 class X { X(int); X operator+(Y); } class Y { Y(X); Y operator+(X); operator int(); friend X operator*(X,Y); } 上面的定义简写了。 想问,如果X x, Y y, int a; ret=x+y+2; 这句是先执行x+y还是y+2