The enum values need to be available to the compiler when it is compiling code that uses them, so you can't isolate them out into a .cpp file like that.
Just declare the enum values in the .h file. As long as you have header guards so it can't be included in any one unit more than once, it will be fine.
I can't see a problem with the const int though. Does it compile if you take the extern-ed enumeration out?
Oh, and to extern your array of states, do this (actually, all the code):
states.h
#ifndef STATES_H#define STATES_Henum State { happy,sad,mad };extern const int NUM_PEOPLE;extern State Person[]; // do not provide the size here#endif
state.cpp
#include "state.h"const int NUM_PEOPLE=300;State Person[NUM_PEOPLE];
Another unit can now include state.h, link to state.obj and access the Person array and NUM_PEOPLE constant.
main.cpp
#include "state.h"int main(){ for(int i=0;i<NUM_PEOPLE;++i) Person=happy; return 0;}
If the enum values were defined inside state.cpp, they would not be available to the compiler when it was compiling main.cpp so the above code could not possibly work. You can have a local enum inside a .cpp that is only used in that unit, but this is why you could not extern an enum as you have attempted to do.
HTH Paul