, , .
enum {
A,
B,
C,
}
May
enum {
A = 0,
B = A + 1,
C = B + 1,
}
int a = A;
a++;
,
enum {
A = 2,
B = 4,
C = 8,
}
+1 .
, ,
enum {
FIRST,
A = FIRST,
B,
C,
LAST = C
}
A C ?
What is the purpose of repeating an enumeration? Do you want to do "for all" or for some subset, is there really an enumeration order?
I would drop them all in a container and repeat, instead
- unordered - use a set
- ordered - vector or list
source
share