6

Say I have

enum Foo { Foo0, Foo1, Foo2 };

Note that no explicitly declared Foo constant has the value 3 (they are 0, 1, and 2).

Does the following invoke undefined behavior?

Foo yay = (Foo) 3;

Note expecially that 3 might fit into the internal representation of Foo.

4

1 回答 1

8

它的定义很好。为了表示值012,类型Foo必须至少有两位,这也足以表示3

于 2012-12-13T23:08:21.207 回答