Enum.4: Define operations on enumerations for safe and simple use
Enum.4:为枚举类型定义运算符以便安全又简单地使用
Reason(原因)
Convenience of use and avoidance of errors.
方便使用又少犯错。
Example(示例)
The use of a static_cast is not pretty, but
static_cast的用法不太好,但是:
is an infinite recursion, and writing it without a cast, using a switch on all cases is long-winded.
是一个特别深的递归,如果不用cast,使用覆盖所有情况的switch语句又会过于繁杂。
Enforcement(实施建议)
Flag repeated expressions cast back into an enumeration.
标记反复转换,最后变成枚举类型的表达式。
原文链接:
觉得本文有帮助?欢迎点赞并分享给更多的人。
阅读更多更新文章,请关注微信公众号【面向对象思考】