以下是我想通過從用戶獲取值來構建的模板矩陣。 但是當我編譯它。我正在低於錯誤。爲什麼錯誤?C++,模板參數錯誤
SO_template.cpp: 在成員函數void Matrix<T>::BuildMatrix(std::vector<T, std::allocator<_CharT> >)': SO_template.cpp:44: error: expected
;'之前「它」
如果我使用int專門化我的類它不會抱怨爲什麼?
template<class T>
class Matrix
{
private:
vector<T> col;
int iNumberOfRow;
int iNumberOfCol;
public:
void BuildMatrix(const std::vector<T> stringArray)
{
std::vector<T>::iterator it= stringArray.begin();
cout<<"Build Matrix irow="<<stringArray.size();
...
...
}
};
可能重複[在哪裏,爲什麼我必須把「模板」和「類型名稱」關鍵字?](HTTP://計算器。 com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords) – 2012-03-16 13:18:20