私のコンパイラは、私が完全に理解できないこのインスタンス化エラーで私を苦しめています。
私はテンプレートクラスlistItemを持っています:
template <class T>
class tListItem{
public:
tListItem(T t){tData=t; next=0;}
tListItem *next;
T data(){return tData;}
private:
T tData;
};
たとえば、次のような非プリミティブデータ型でオブジェクトを初期化しようとすると:
sPacket zomg("whaever",1);
tListItem<sPacket> z(zomg);
私のコンパイラは常にこのエラーをスローします.エラーはプリミティブ型ではスローされません。
コンパイラからの出力は次のとおりです。
../linkedList/tListItem.h: In constructor ‘tListItem<T>::tListItem(T) [with T = sPacket]’:
recvBufTest.cpp:15: instantiated from here
../linkedList/tListItem.h:4: error: no matching function for call to ‘sPacket::sPacket()’
../packetz/sPacket.h:2: note: candidates are: sPacket::sPacket(const char*, int)
../packetz/sPacket.h:1: note: sPacket::sPacket(const sPacket&)
私はあなたに迷惑をかけませんが、私は何か愚かなことで2時間を過ごしたくありません.....