You cannot set default values for your enumeration members, only for a full enumeration. The default value for it is 0 , which refers to the first element of the enumeration. Other members of the enumeration must differ from this value, otherwise they simply redefine it. In this case:
enum Foo { Bar=0, Baz=0, bread=0, jam=0 };
You tell the compiler: OK, now they will be called 0 as Bar . So now 0 will be called Baz and so on. This makes no sense to the compiler.
In the Code Complete book, you can find advice on introducing a default enumeration member named None and explicitly assign it 0 and put it in the first place of your enumeration. So your code might look like this:
enum Foo { None = 0, Bar, // 1 Baz, // 2 bread, // 3 jam // 4 };
VMAtm source share