我有这个错误:
Undefined symbols for architecture x86_64:
"my::Queue<int>::Queue()", referenced from:
_main in ccdwI88X.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
对于此代码“main.cpp”:
#include "Queue.hpp"
int main()
{
my::Queue<int> myqueue;
return 0;
}
'队列.hpp':
#ifndef QUEUE_HH__
#define QUEUE_HH__
namespace my
{
template <typename T>
class Queue
{
public:
Queue();
};
}
#endif
和“队列.cpp”:
#include "Queue.hpp"
template <typename T>
my::Queue<T>::Queue()
{
}