link 的问题
求解答
错误:ObjCounter<TestApp>::ObjCounter<TestApp>() 中的 init函数external link error
两个类的头文件 Code如下:
#ifndef OBJ_COUNTER_HH
#define OBJ_COUNTER_HH
template <class T>
class ObjCounter
{
public:
class TooManyObjects
{
};
private:
void init();
protected:
~ObjCounter();
ObjCounter(const ObjCounter&);
ObjCounter();
private:
static int m_iCurNum;
static const int m_iMaxNum;
ObjCounter& operator=(const ObjCounter&);
};
#endif
#ifndef APP_TESTER_HH
#define APP_TESTER_HH
#include "ObjCounter.h"
//class ObjCounter;
class TestApp : private ObjCounter<TestApp>
{
public:
~TestApp(){};
using ObjCounter<TestApp>::TooManyObjects;
static TestApp* CreateTestApp();
static TestApp* CreateTestApp(const TestApp&);
private:
TestApp(){}
TestApp(const TestApp&);
};
#endif