C99(ISO/IEC 9899:1999)中规定enum的类型为int
Ch 6.7.2.2
Constraints
2 The expression that defines the value of an enumeration constant shall be an integer constant expression that has a value representable as an int.
Semantics
3 The identifiers in an enumerator list are declared as constants that have type int and may appear wherever such are permitted.
C++2003(ISO/IEC 14882:2003)则规定enum在“能用int表示时类型为范围不大于int的整型”,即如果int不能表示则可以使用更宽的整型。
Ch 7.2
The underlying type of an enumeration is an integral type that can represent all the enumerator values defined in the enumeration. It is implementation-defined which integral type is used as the underlying type for an enumeration except that the underlying type shall not be larger than int unless the value of an enumerator cannot fit in an int or unsigned int.
注意,unsigned int和int的宽度一样。
星期二, 四月 21, 2009
星期日, 四月 19, 2009
星期四, 四月 16, 2009
本来应该放到自留地的东西
理性和感性这两个东西的共存常常会困扰我。
首先,让这两者互不影响就是一件十分困难的事情。在不同的情况下使用不同的思考模式,或者说不让情感影响思考,同时又保持人的特征,是一个巨大的挑战。
另一方面,即使选择了正确的思维模式,仍然会出现理性(或者说逻辑)不能解决所有问题的时候,起码依靠逻辑判断的速度远不如依靠直觉来得快。所以,即使选择了完全的理性,也仍然不能摆脱非理性的部分。
这一点曾经让我十分困惑不解,为什么两个几乎是势不两立思维模式却分不开呢?有一天,祖先的智慧让我豁然开朗,解释了这个难题,也揭示了事物的本质。我想到的就是:太极图。
首先,让这两者互不影响就是一件十分困难的事情。在不同的情况下使用不同的思考模式,或者说不让情感影响思考,同时又保持人的特征,是一个巨大的挑战。
另一方面,即使选择了正确的思维模式,仍然会出现理性(或者说逻辑)不能解决所有问题的时候,起码依靠逻辑判断的速度远不如依靠直觉来得快。所以,即使选择了完全的理性,也仍然不能摆脱非理性的部分。
这一点曾经让我十分困惑不解,为什么两个几乎是势不两立思维模式却分不开呢?有一天,祖先的智慧让我豁然开朗,解释了这个难题,也揭示了事物的本质。我想到的就是:太极图。
订阅:
评论 (Atom)