`
prevention
  • 浏览: 71625 次
社区版块
存档分类
最新评论

Why do people use enums in C++ as constants while they can use const?

 
阅读更多

Often you'll see enum { SOMETHING = 2232; } (like that; unnamed enum with one value only) instead of const int SOMETHING = 2232;. It's because enum never gets any storage while const variable is still a variable and will get (static) storage if the compiler can't proove it won't need one, which it often can't.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics