Difference between Enum and Define Statements

后端 未结 18 2570
终归单人心
终归单人心 2020-11-30 00:27

What\'s the difference between using a define statement and an enum statement in C/C++ (and is there any difference when using them with either C or C++)?

For exampl

18条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 00:55

    In addition to the good points listed above, you can limit the scope of enums to a class, struct or namespace. Personally, I like to have the minimum number of relevent symbols in scope at any one time which is another reason for using enums rather than #defines.

提交回复
热议问题