0
난 내 자신의 블록 큐를 만들었으며 나는 (이 비주얼 스튜디오 2010 년 Qt는 응용 프로그램입니다 주) 링커 오류가 발생 이유를 알아내는 몇 가지 문제에 봉착 :되지 않은 외부 기호
#ifndef BLOCKING_QUEUE_H
#define BLOCKING_QUEUE_H
#include <QObject>
#include <QSharedPointer>
#include <QWaitCondition>
#include <QMutex>
#include <queue>
namespace TestingNS
{
template<typename Data>
class BlockingQueue
{
private:
std::queue<QSharedPointer<Data>> _queue;
QMutex _mutex;
QWaitCondition _monitor;
volatile bool _closed;
public:
BlockingQueue();
void Close();
size_t Size();
void Empty();
bool IsClosed();
bool Enqueue(QSharedPointer<Data> data);
bool TryDequeue(QSharedPointer<Data>& value, unsigned long time = ULONG_MAX);
};
}
#endif //BLOCKING_QUEUE_H
구현은 조금 더, 그래서 그것에 대한 pastie 있습니다 http://pastie.org/5368660
프로그램 진입 점은 다음과 같습니다
#include <QtCore/QCoreApplication>
#include <QTimer>
#include <iostream>
#include "BlockingQueue.h"
using namespace std;
using namespace TestingNS;
class Item
{
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
BlockingQueue<Item> queue;
cout << "Press any key to exit!" << endl;
char in;
cin.get(in);
QTimer::singleShot(0, &a, SLOT(quit()));
return a.exec();
}
링커 내가 얻을 오류 : 링커가 생성자 (도 BlockingQueue
에서 다른 방법을) 찾을 수없는 이유 이해가 안
Error 1 error LNK2019: unresolved external symbol "public: __thiscall TestingNS::BlockingQueue<class Item>::BlockingQueue<class Item>(void)" ([email protected]@@@[email protected]@[email protected]) referenced in function _main
. 어떤 아이디어?
BlockingQueue 구현은 어디에 있습니까? – imreal
[템플릿을 헤더 파일에만 구현할 수있는 이유는 무엇입니까?] (http://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header- 파일). –
@ 닉 내 질문에 pastie 링크를 참조하십시오. – Kiril