14.2 Operators

Expressions are constructed from operands and operators. The operators of an
expression indicate which
operations to apply to the operands. [Example: Examples of operators
include +, -, *, /, and new. Examples
of operands include literals, fields, local variables, and expressions. end
example]
There are three kinds of operators:
?Unary operators. The unary operators take one operand and use either
prefix notation (such as ?x) or
postfix notation (such as x++).
?Binary operators. The binary operators take two operands and all use
infix notation (such as x + y).
?Ternary operator. Only one ternary operator, ?:, exists; it takes three
operands and uses infix notation
(c ? x : y).
The order of evaluation of operators in an expression is determined by the
precedence and associativity of
the operators (?4.2.1).
The order in which operands in an expression are evaluated, is left to
right. [Example: For example, in
F(i) + G(i++) * H(i), method F is called using the old value of i, then
method G is called with the old
value of i, and, finally, method H is called with the new value of i. This
is separate from and unrelated to
operator precedence. end example] Certain operators can be overloaded.
Operator overloading permits userdefined
operator implementations to be specified for operations where one or both
of the operands are of a
user-defined class or struct type (?4.2.2).
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值