What is the purpose of anonymous enum declarations such as:
enum
enum { color = 1 };
Why not just declare int color = 1?
int color = 1
That's a so-called enum trick for declaring a compile-time integer constant. It's advantage is it guarantees that no variable is instantiated and therefore there's no runtime overhead. Most compilers introduce no overhead with integer constants anyway.
2.1m questions
2.1m answers
60 comments
57.0k users