Hello gurus,
I know this question doesn't really belong to VC++ section, but here goes anyway....
I'd like to automatically detect how many elements my 'enum' data structure contains, something like
Code:enum ENUM1 { A = -4, B, C, D, E }; printf("%d\n", MagicFunctionThatReturnsNumOfElementsInENUM1() );
??? sizeof(ENUM1) always returns 4
I guess I could write
but then I gotta know the names of the first and last element of the enum...Code:int MagicFunctionThatReturnsNumOfElementsInENUM1() { return (E-A+1); }
Furthermore, this wouldn't work with enums like this
Any ideas? Is it even doable?Code:enum ENUM1 { A, B, C=56, D, E };




Reply With Quote