conversion(c++)# Programming - 葵花宝典
g*e
1 楼
Consider two possible interpreations of the following case
class x{
...
x(int);
friend x operator+ (x,x){...}
operator int(){...}
};
now in code
x y,z; ...some assignment afterwards...
y=z+2;
question: two possible conversions: z to int, then +2 ,then to x.
another way:2 to x then + z.
is this case allowable in C++ syntax?
class x{
...
x(int);
friend x operator+ (x,x){...}
operator int(){...}
};
now in code
x y,z; ...some assignment afterwards...
y=z+2;
question: two possible conversions: z to int, then +2 ,then to x.
another way:2 to x then + z.
is this case allowable in C++ syntax?