다음은 사용자로부터 가치를 얻으려는 템플릿 매트릭스입니다. 하지만 컴파일 할 때. 오류가 발생했습니다. 왜 오류입니까?C++, 템플릿 인자 에러
SO_template.cpp : 회원 기능 void Matrix<T>::BuildMatrix(std::vector<T, std::allocator<_CharT> >)': SO_template.cpp:44: error: expected
에서 ' before "it"
int를 사용하여 클래스를 특수화하면 왜 불만을 나타내지 않습니까? 전체 유형 T
에 따라 달라집니다 -
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-the-template-and-typename- 키워드) –