M
Morgan Cheng
Hi,
In my program module, there are some Constants should be defined to be
integer key value of std::map. In the module, methods of a few classes
will return std::map containing value indexed by constant integer key value.
I am wondering what is a good way to define these constants.
1) #define A = 0
#define B = 1
#define C = 2
2) enum {
A, B, C
}
3) class AbcConstant {
enum {
A, B, C
}
};
Which one is best? I prefer option 3, because usage of constant should
be AbcConstant::A or AbcConstant::B, it is clear that the constants are
defined in class AbcConstant.
Any recommmendation?
In my program module, there are some Constants should be defined to be
integer key value of std::map. In the module, methods of a few classes
will return std::map containing value indexed by constant integer key value.
I am wondering what is a good way to define these constants.
1) #define A = 0
#define B = 1
#define C = 2
2) enum {
A, B, C
}
3) class AbcConstant {
enum {
A, B, C
}
};
Which one is best? I prefer option 3, because usage of constant should
be AbcConstant::A or AbcConstant::B, it is clear that the constants are
defined in class AbcConstant.
Any recommmendation?