Operator can be overloaded only as a relational comparison operator , not as an assignment operator 运算符只能作为关系比较运算符重载,而不能作为赋值运算符重载。
And the language supports operator overloading , you should overload the equality operator for your value type 并且语言支持运算符重载,应重载值类型的相等运算符。
Avoid defining operator overloads , except in types that should work like primitive built - in types 避免定义运算符重载,但在其用法应类似于基元(内置)类型的类型中除外。
Shows how you can use operator overloading to create a complex number class complex that defines complex addition 显示如何使用运算符重载创建定义复数加法的复数类complex 。
Do not provide operator overloads unless at least one of the operands is of the type defining the overload 除非至少有一个操作数属于定义重载的类型,否则不要提供运算符重载。
Compilers that choose to support operator overloading should follow these guidelines but are not required to do so 要支持运算符重载的编译器应该遵循这些指南,但这不是必须的。
Operator overloading is useful in cases where it is immediately obvious what the result of the operation will be 当重载运算符后运算结果非常直观的情况下才适于进行运算符重载。
This sample demonstrates new language features in visual basic , including generics , operator overloading , and the 本示例演示了visual basic中的新语言功能,包括泛型、运算符重载和
For languages that do not support operator overloading , you can invoke these members by using alternative method syntax 对于不支持运算符重载的语言,可以通过使用其他方法语法来调用这些成员。
By adding operator overloads to a type , you allow developers to use the type as though it were a built - in primitive type 通过在类型中添加运算符重载,开发人员可以像使用内置基元类型一样使用该类型。