可能重複:
Where and why do I have to put the 「template」 and 「typename」 keywords?如何爲泛型類型的向量聲明一個迭代器?
我聲明爲是一個通用類型的矢量的迭代器的問題。 代碼如下:
template <class T> void print(const vector<T>& V)
{
vector<T>::const_iterator i;
}
下面返回預期的誤差;於我之前'。 如果我特別說明,將不會有錯誤vector<int>::const_iterator i;
有沒有辦法解決這個問題?
'類型名稱矢量 ::爲const_iterator我;' –
hmjd