Reputation: 63
Can someone please explain to me which part is what in this:
enum bb { cc } dd;
I understand that enum bb
is the name of the enumeration and that { cc }
is its enumerator, but I have no clue what dd
is.
Upvotes: 0
Views: 77
Reputation: 4663
It defines dd
as a variable of the type enum bb
. Take a look at Enumerations
It behaves just like when you're defining normally
#include <stdio.h>
int main()
{
enum bb { cc, ee } dd = cc; // dd is now 0
dd = ee; // dd is now 1
printf("%d", dd);
}
Link.
Upvotes: 1
Reputation: 67476
enum bb
{
cc
} dd;
bb
- enum tag.cc
- enumerator constant. As it is first and it does not have an expicity defined value it will be zero (0
);dd
- variable of type enum bb
It can be written as:
enum bb
{
cc
};
enum bb dd;
Upvotes: 3