我有以下模板法,與自定義模板STL迭代器
template <class T>
void Class::setData(vector<T> data)
{
vector<T>::iterator it;
}
,我得到以下編譯錯誤(的XCode/GCC)
error: expected `;' before 'it'
我發現別人有類似問題here (read down to see it's the same even though it starts out with a different issue)但它們似乎已通過更新Visual Studio解決。這讓我猜測這是一個編譯器問題,它應該編譯,是否正確?通過索引從0到大小的迭代工作,但它不是我喜歡實現此功能的方式。有沒有其他的方法呢? 感謝
注:考慮通過在「矢量和數據」,也可能「矢量常量與數據」不「矢量數據」。前兩個將傳入一個向量的引用,後者將完成向量的複製。 –
2009-02-27 13:16:56
當然,這只是一個例子:) – DavidG 2009-03-02 11:26:24