MrJim
public text v1 · immutableQ6.
Here are several different ways to declare constants. What are the pros and cons of each?
A.
#define INDEX_1 0
#define INDEX_2 1
#define INDEX_3 2
#define MAX_INDEX 3
B.
enum
{
INDEX_1 = 0,
INDEX_2,
INDEX_3,
MAX_INDEX
};
C.
typedef enum
{
INDEX_1 = 0,
INDEX_2,
INDEX_3,
MAX_INDEX
} INDEX_TYPE;
D.
static const int
INDEX_1 = 0,
INDEX_2 = 1,
INDEX_3 = 2,
MAX_INDEX = 3;
E.
int
INDEX_1 = 0,
INDEX_2 = 1,
INDEX_3 = 2,
MAX_INDEX = 3;