D-programming-unary-operators-overloading
提供:Dev Guides
単項演算子のオーバーロード
次の表に、単項演算子のリストとその目的を示します。
Function Name | Operator | Purpose |
---|---|---|
opUnary | - | Negative of (numeric complement of) |
opUnary | + | The same value as (or, a copy of) |
opUnary | ~ | Bitwise negation |
opUnary | * | Access to what it points to |
opUnary | ++ | Increment |
opUnary | — | Decrement |
以下に、バイナリ演算子をオーバーロードする方法を説明する例を示します。
上記のコードをコンパイルして実行すると、次の結果が生成されます-