关闭

17.9.2 Binary operators

674人阅读 评论(0) 收藏 举报
A binary operator must take two parameters, at least one of which must have
the class or struct type in which the
operator is declared. The shift operators (§14.8) are further constrained:
The type of the first parameter must be
the class or struct type in which the operator is declared, and the second
parameter must always have the type
int. A binary operator can return any type.
The signature of a binary operator consists of the operator token (+, -, *,
/, %, &, |, ^, <<, >>, ==, !=, >, <, >=, or
<=) and the types of the two formal parameters. The return type and the
names of the formal parameters are not
part of a binary operator?s signature.
Certain binary operators require pair-wise declaration. For every
declaration of either operator of a pair, there
must be a matching declaration of the other operator of the pair. Two
operator declarations match when they have
the same return type and the same type for each parameter. The following
operators require pair-wise declaration:
? operator == and operator !=
? operator > and operator <
? operator >= and operator <=
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:566073次
    • 积分:11486
    • 等级:
    • 排名:第1344名
    • 原创:565篇
    • 转载:0篇
    • 译文:0篇
    • 评论:50条
    文章分类