为什么会这样?为什么
老田低代码 2005-04-09 10:49:32 我现在正在学习C++,但是这些问题实在是很打击我哦。。。没有人旁边指导,日子。。苦!!!!
#include "tstack.h"
void main()
{
TStack<int> istack;
for(int ix=1;ix<10;ix++)
{
istack.push(ix);
}
istack.display();
}
出现的错误提示:
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall TStack<int>::display(void)" (?display@?$TStack@H@@QAEXXZ)
main.obj : error LNK2001: unresolved external symbol "public: bool __thiscall TStack<int>::push(int)" (?push@?$TStack@H@@QAE_NH@Z)
Debug/TStack.exe : fatal error LNK1120: 2 unresolved externals
但是我在类实现中TStack.cpp
template <class T>
bool TStack<T>::push(T value)
{
if (_size==100)
return false;
_stacklist[++_top]=value;
_size=_size+1;
return true;
}
template <class T>
void TStack<T>::display()
{
for(in ix=0;ix<=_top;ix++)
cout<<_stacklist[ix]<<" ";
cout<<endl;
}
以及在类定义中:
template <class T>
class TStack
{
public:
TStack():_size(0),_top(0){}
bool pop(T &value);
bool push(T value);
void display();
private:
int _size;
int _top;
T _stacklist[100];
};
但是就是出现上面的提示,为什么??