爲什麼下面不能編譯(MSVC10 - 但我懷疑它不是有效的C++),並且有沒有解決方法?使用成員類型的模板類作爲類成員變量
template <typename M>
struct MyClass
{
typedef std::vector<M>::iterator iteratorT;
iteratorT myIterator;
};
錯誤是error C2146: syntax error : missing ';' before identifier 'iteratorT'
。我已經嘗試了一堆變體,結果相同:可以使用std::vector<M>::iterator
作爲成員函數中的類型,但不能將其作爲成員變量的類型。
一個相當常見的FAQ。看到這裏http://www.parashift.com/c++-faq-lite/templates.html#faq-35.18 – AnT
謝謝 - 我不知道該找什麼來尋找答案! – Zero