枚举类型本质

来源:互联网 发布:mac os x最新版本好吗 编辑:程序博客网 时间:2024/04/29 03:09

枚举类型内存中占用空间

#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
    enum color{ r,g,b};
    color c;
    cout <<sizeof(c)<<endl;
    return 0;
}

返回

4
------------------
(program exited with code: 0)
Press return to continue

枚举类型的实质是int型;

0 0
原创粉丝点击