1
스택 클래스에서 작업 중이며 두 개의 생성자가 있습니다. 관심의 하나는 이것입니다.템플릿 클래스의 동적 생성자
template <typename T>
stack<T>::stack(const int n)
{
capacity = n ;
size = 0 ;
arr = new T [capacity] ;
}
나는 메인처럼 이것을 부르고있다.
stack<int> s1(3) ;
프로그램은 정상적으로 컴파일되지만이 런타임 오류가 발생합니다.
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall
stack<int>::~stack<int>(void)" ([email protected]@@[email protected]) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall
stack<int>::stack<int>(int)" ([email protected]@@[email protected]@Z) referenced in function _main
1>D:\\Microsoft Visual Studio 10.0\Visual Studio 2010\Projects\Expression
Evaluation\Debug\Expression Evaluation.exe : fatal error LNK1120: 2 unresolved externals
저는 Microsoft visual studio 2010
에서 일하고 있습니다.이 문제는 어디에도 없습니다. 힌트를 보내 주시면 감사하겠습니다.
이 정규 수업과 다른 :
그래서 기본적으로이 할 템플릿 *을 인스턴스화하는 코드 만이 사용할 구체적인 유형을 알고 있기 때문에 * (즉,'stack.cpp')가 구현되었습니다. – willglynn
괜찮습니다. 감사합니다. 그 이유는 과 @wilglynn입니다. – Sasha