what is the meaning of: return _a != MAX_A_VAL
? I've not seen conditionals in a return statement beyond ternary operators. What's this? By the way, this was used in an operator bool()
class method.
这意味着进行比较_a != MAX_A_VAL
,然后返回其结果( true
或false
)
It means that if _a
is NOT equal to MAX_A_VAL
it should return true
and otherwise it should return false
It's a boolean comparision.
It may be easier to read like so:
return (_a != MAX_A_VAL);
or another way you could look at it is:
bool retvalue = (_a != MAX_A_VAL);
return retvalue;
return
语句可以使用任何表达式作为其返回值,它不必像变量一样简单。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.