2

最近我在<QMap>标题中遇到了这样的代码。

#include <iostream>

class Something
{
public:
    int a : 42;   // What does this mean?
};

int main()
{
    Something something;
    std::cout << something.a << std::endl;
    return 0;
}

它似乎不是初始化,因为程序输出0.

我也收到一个奇怪的警告:

main.cpp:6: warning: width of 'Something::a' 
exceeds its type [enabled by default]
4

0 回答 0