Defining an operator in this way is called operator overloading , whether or not you use the 通過(guò)這種方式定義運(yùn)算符的過(guò)程稱(chēng)為運(yùn)算符重載,不管您是否使用了
And the language supports operator overloading , you should overload the equality operator for your value type 并且語(yǔ)言支持運(yùn)算符重載,應(yīng)重載值類(lèi)型的相等運(yùn)算符。
Avoid defining operator overloads , except in types that should work like primitive built - in types 避免定義運(yùn)算符重載,但在其用法應(yīng)類(lèi)似于基元(內(nèi)置)類(lèi)型的類(lèi)型中除外。
Shows how you can use operator overloading to create a complex number class complex that defines complex addition 顯示如何使用運(yùn)算符重載創(chuàng)建定義復(fù)數(shù)加法的復(fù)數(shù)類(lèi)complex 。
Do not provide operator overloads unless at least one of the operands is of the type defining the overload 除非至少有一個(gè)操作數(shù)屬于定義重載的類(lèi)型,否則不要提供運(yùn)算符重載。
Compilers that choose to support operator overloading should follow these guidelines but are not required to do so 要支持運(yùn)算符重載的編譯器應(yīng)該遵循這些指南,但這不是必須的。
Operator overloading is useful in cases where it is immediately obvious what the result of the operation will be 當(dāng)重載運(yùn)算符后運(yùn)算結(jié)果非常直觀(guān)的情況下才適于進(jìn)行運(yùn)算符重載。
This sample demonstrates new language features in visual basic , including generics , operator overloading , and the 本示例演示了visual basic中的新語(yǔ)言功能,包括泛型、運(yùn)算符重載和
For languages that do not support operator overloading , you can invoke these members by using alternative method syntax 對(duì)于不支持運(yùn)算符重載的語(yǔ)言,可以通過(guò)使用其他方法語(yǔ)法來(lái)調(diào)用這些成員。
By adding operator overloads to a type , you allow developers to use the type as though it were a built - in primitive type 通過(guò)在類(lèi)型中添加運(yùn)算符重載,開(kāi)發(fā)人員可以像使用內(nèi)置基元類(lèi)型一樣使用該類(lèi)型。
In object-oriented programming, operator overloading?less commonly known as operator ad-hoc polymorphism?is a specific case of polymorphism, where different operators have different implementations depending on their arguments. Operator overloading is generally defined by the language, the programmer, or both.