For an operation of the form !x, unary operator overload resolution (?4.2.3)
is applied to select a specific
operator implementation. The operand is converted to the parameter type of
the selected operator, and the
type of the result is the return type of the operator. Only one predefined
logical negation operator exists:
bool operator !(bool x);
This operator computes the logical negation of the operand: If the operand
is true, the result is false. If
the operand is false, the result is true.
is applied to select a specific
operator implementation. The operand is converted to the parameter type of
the selected operator, and the
type of the result is the return type of the operator. Only one predefined
logical negation operator exists:
bool operator !(bool x);
This operator computes the logical negation of the operand: If the operand
is true, the result is false. If
the operand is false, the result is true.
本文介绍了C++中逻辑非运算符!的基本用法及其类型转换规则。对于形式为!x的操作,将应用一元运算符重载解析来选择特定的运算符实现。操作数将被转换为所选运算符的参数类型,而结果的类型则是该运算符的返回类型。预定义的逻辑非运算符只有一个:bool operator!(bool x),该运算符计算操作数的逻辑否定。
283

被折叠的 条评论
为什么被折叠?



