What is the purpose of anonymous enum
declarations such as:
enum { color = 1 };
Why not just declare int color = 1
?
What is the purpose of anonymous enum
declarations such as:
enum { color = 1 };
Why not just declare 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.