enum Country {USA, China, ..., Jamaica, FIRST_COUNTRY = USA, LAST_COUNTRY = Jamaica, NUM_COUNTRIES};
struct Crowd {
int numAmericans;
int numPeople[NUM_COUNTRIES]; // Generalizing the above
}
// ...
int main () {
constint numCrowds = 10;
Crowd crowd[numCrowds];
int Crowd::*num[NUM_COUNTRIES];
for (int i = 0; i < numCrowds; i++)
{
num[USA] = &Crowd::numAmericans; // This compiles
for (int COUNTRY = FIRST_COUNTRY; COUNTRY <= LAST_COUNTRY; COUNTRY++) // Attempting to generalize
num[COUNTRY] = &Crowd::numPeople[COUNTRY]; // Won't compile. Why?
//...
}
}
P.S. My entire program runs fine if I repeat num[USA] = &Crowd::numAmericans; for AAALLL the other countries. Just trying to do it with a for-loop instead.