Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • provide no explicit integer assignments, for as in this example:
Code Block
bgColor#ccccff
enum {red, orange, yellow, green, blue, indigo, violet};
  • assign a value to the first member only (the rest are then sequential), for as in this example:
Code Block
bgColor#ccccff
enum {red=4, orange, yellow, green, blue, indigo, violet};
  • assign a value to all members , so any equivalence is explicit, for as in this example:
Code Block
bgColor#ccccff
enum {red=4, orange=5, yellow=6, green=7, blue=8, indigo=6, violet=7};

It is also advisable to provide a comment explaning explaining why multiple enumeration type members are being assigned the same value so that future maintainers don't mistakenly identify this as an error.

...