• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Array of size enum in C++

xrax

Senior member
Is there a way to make an array that has the same amount of elements as an enum typedef?
typedef enum

{
A, B, C

} Enum_Types;

typedef double Enum_Array[ ??? ];
 
Originally posted by: BFG10K
Use the last Enum value as your array size.

Enum_Array [C] in your case.

A common practice is to have hte enums as follows:

{A,
B,
C,
MIN= A,
MAX = C
}

Then make your array size MAX.

TYhen if the enum list ever changes ... you can reassign MAX as desired and all your code should still work. Imagine if you used C in 100 places then decided C nees to be deleted 😉
 
Back
Top