链接器不能识别重载函数,这是为什么呢?
template<typename T> class CPVRTSingleton
{
private:
CPVRTSingleton(const CPVRTSingleton&);
CPVRTSingleton & operator=(const CPVRTSingleton&);
public:
static T& inst()
{
static T object;
return object;
}
static T* ptr()
{
return &inst();
}
protected:
CPVRTSingleton() {};
virtual ~CPVRTSingleton() {};
};这是一个基类,继承过来,
class TextureManager : public CPVRTSingleton<TextureManager>
{
public:
TextureManager(){};
~TextureManager();//cpp里有实现
TextureManager(int i32TotalTextures);//cpp里有实现
....
}
奇怪的问题出现了,我定义一个TextureManager的对象,会报链接错误,无法识别析构函数。我改为定义一个对象指针,如果有new 操作,也会报这个链接错误,会不识别第二个构造函数和析构函数。如果只是个空指针,则可以通过链接,请问这是为什么呢?在线等你们的回答哦。
...全文


