C ++ Typedef和运算符重载

C ++ Typedef和运算符重载

问题描述:

如果定义类似typedef int MY_INT;的类型并继续重载,例如,MY_INT的加法运算符类似

If you define a type like typedef int MY_INT; and go on to overload, say, the adition operator of MY_INT like


MY_INT operator+(MY_INT a, MY_INT b);


MY_INT a, b;
a + b;

不同于


int A, B;
A + B;

?

很抱歉出现任何语法错误.我不在编译器附近,我想在忘记它之前先问这个问题.

Sorry for any syntax errors. I'm not near a compiler and I want to ask this before I forget about it.

否. typedef实际上是另一种类型的别名.原始类型和类型定义的类型相同.

No. A typedef is actually an alias for another type. The original and typedef-ed types are the same.