我已经从GCC-4.7.0的主干版本中构建了MinGW:http://code.google.com/p/mingw-builds/downloads/list。在这个版本的更改说明中,它说实现了非静态数据成员初始化:http://gcc.gnu.org/gcc-4.7/changes.html。http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2756.htm。当我尝试编译这样一个示例时:
我收到了很多错误信息,其中这个是最后一个:
#include <iostream>
#include <string>
struct type {
type()
:i(33)
{}
int i;
std::string s("string");
};
int main() {
type t;
std::cout << t.i << " : " << t.s << std::endl;
}
我收到了很多错误信息,其中这个是最后一个:
但是根据文档,代码是正确的。main.cpp:16:35: 注意:'std::string (type::)(int) {aka std::basic_string (type::)(int)}' 没有继承自 'const std::basic_string<_CharT, _Traits, _Alloc>' main.cpp:16:35: 注意: 无法从重载函数 't.type::s' 解析地址