我是問題的OP:Extending a class其中我收到了很好的答案。然而,當我嘗試編譯代碼(我的項目略有返工)我收到以下消息(線沒有改變,以反映下面的示例代碼。):編譯器錯誤預期的嵌套名稱說明符
except.h: | 09 | expected nested-name-specifier before ‘handler_t1’
還有更多沿着這似乎從這個幹線。我是C++的新手,我對這個答案的研究(以及即將出現的問題)產生了這樣一個事實:微軟的編譯器似乎接受了代碼,但符合標準的代碼卻沒有。
因爲我現在有它的代碼如下:
#include <vector>
namespace except
{
// several other classes and functions which compile and work already
// (tested and verified) have been snipped out. Entire code is over
// 1000 lines.
class Error_Handler
{
public:
using handler_t1 = bool (*)(except::Logic const&);
std::vector<handler_t1> logic_handlers;
// a lot more removed because the error has already happened ...
}
}
A至鏈接問題的代碼的讀取指示給我(我有限的知識),它應該所有的工作。
因此,我的問題是:在此聲明/定義中需要更改哪些內容才能使用gcc編譯(4.6.3 64位Linux編譯時使用-std = C++ 0x)?
我不太瞭解C++ 11,但這有幫助嗎? http://en.cppreference.com/w/cpp/language/type_alias –