Your constructor taking a worker
is not defined. You only have the header, not the definition. This leads to the error
I added the definition in the class declaration as this:
person(T a) { x = a; };
Here is a minimal code that compiles and executes (from what you have done) :
#include <iostream>
class worker
{
private:
int a;
public:
worker(){}
~worker() {}
};
//person.h
template <class T>
class person
{
public:
person();
person(T a) { x = a; };
virtual ~person();
private:
T x;
};
//person.cpp
template <class T>
person<T>::~person()
{
//dtor
}
int main()
{
worker w;
person<worker> people(w);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…