所以我試圖讓這對GCC編寫一些代碼編譯上的Visual Studio 2008年我有我已經縮小到這是一個問題:爲什麼這個類的聲明不是Visual Studio的工作
class value_t
{
public:
typedef std::deque<value_t> sequence_t;
typedef sequence_t::iterator iterator;
};
此代碼失敗:
1>cpptest.cpp
1>c:\program files\microsoft visual studio 9.0\vc\include\deque(518) : error C2027: use of undefined type 'value_t'
1> c:\temp\cpptest\cpptest.cpp(10) : see declaration of 'value_t'
1> c:\temp\cpptest\cpptest.cpp(13) : see reference to class template instantiation 'std::deque<_Ty>' being compiled
1> with
1> [
1> _Ty=value_t
1> ]
1>c:\program files\microsoft visual studio 9.0\vc\include\deque(518) : error C2027: use of undefined type 'value_t'
1> c:\temp\cpptest\cpptest.cpp(10) : see declaration of 'value_t'
然而,當我嘗試用這個的std ::向量,它編譯罰款:
class value_t
{
public:
typedef std::vector<value_t> sequence_t;
typedef sequence_t::iterator iterator;
};
瓦在錯誤?我曾嘗試在我能想到的任何地方添加'typename',但此時我認爲這只是Dinkumware STL中的一個錯誤。任何人都可以解釋發生了什麼,和/或提供解決方案?謝謝。
「你能想到的地方」是否包含'typedef typename sequence_t :: iterator iterator;'? – Stephen 2010-06-10 18:46:23
您可以在類聲明前嘗試前向聲明。即class_value_t; – 2010-06-10 18:46:36
好吧,這總是發生 - 我發佈這個問題後,我發現在谷歌魔術組合給我一些相關的東西。參見http://www.gamedev.net/community/forums/topic.asp?topic_id=295828其中討論了這個主題;仍然不提供解決方案。有人可以證實,在這種情況下使用deque是非標準的嗎?有沒有辦法讓這個工作不需要更改文件? –
Roel
2010-06-10 18:46:48