您的位置:首页 > 编程语言 > C语言/C++

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

2013-04-20 21:32 501 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐