enum và #define xuất hiện để có thể làm điều tương tự, ví dụ dưới đây xác định kiểu. Hiểu rằng #define là thay thế macro cho trình tiền xử lý biên dịch. Có trường hợp nào được ưu tiên hơn trường hợp khác không?enum hoặc xác định, cái nào tôi nên sử dụng?
typedef enum {
SelectionStyleNone,
SelectionStyleBlue,
SelectionStyleRed
} SelectionStyle;
vs
#define SELECTION_STYLE_NONE 0
#define SELECTION_STYLE_BLUE 1
#define SELECTION_STYLE_RED 2
Xem thêm: [Tôi có nên sử dụng #define, enum hoặc const?] (Http://stackoverflow.com/questions/112433/should-i-use-define-enum-or-const) – Shog9