可能重复:
Why should the implementation and the declaration of a template class be in the same header file?
我正在编写我的第一个涉及模板类的程序,而我刚刚编写的代码我得到了这个错误......
Undefined symbols for architecture x86_64:
"Queue<int>::Queue()", referenced from:
_main in cc1qqasg.o
"Queue<int>::~Queue()", referenced from:
_main in cc1qqasg.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
我相当肯定我在以下代码中某处出现了某种语法错误......
//主
int main()
{
Queue <int> myQ;
return 0;
}
// class
template <class qType>
class Queue
{
public:
Queue();
~Queue();
};
//实施
template <class qType>
Queue<qType>::Queue()
{
}
template <class qType>
Queue<qType>::~Queue()
{
}
感谢您的帮助。