我已經建立的MinGW從主幹版本GCC-4.7.0: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(類型:: )(INT){又名 STD :: basic_string(type ::)(int)}'不是從'const std :: basic_string < _CharT,_Traits,_Alloc>'main.cpp:16:35:note: 無法解析重載地址函數't.type :: s'
但根據文檔,代碼是正確的。
我沒有安裝GCC 4.7來測試它,我的版本沒有支持成員初始化,但是你用-std = C++ 0x標誌來編譯它嗎? – Griwes
請注意,成員初始值設定項對於GCC 4.7是新增的,所以它應該是一個簡單的編譯器錯誤。給Griwes的 –
:是的。 – niXman