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.
1.4m articles
1.4m replys
5 comments
57.0k users