c++ - Difference between Enum and Define Statements -
What is the difference between a defined statement in C / C ++ and an enum statement (and any differences when using it Either C or C ++)?
For example, when using
enum {BUFFER = 1234};
more
define # buffer 1234
enum
defines a syntax element.
Generally, these are preferred because they are type-safe and more easily searchable. To define, it is hard work and can be complicated behavior, for example a piece of code can redefine any other code by #define
. It can be difficult to track.
Comments
Post a Comment