link 的问题

zhouwei1983426 2014-02-12 05:47:54
求解答
错误: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
...全文
77 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouwei1983426 2014-02-13
  • 打赏
  • 举报
回复
我不太明白我哪里有问题。 想了半天没明白为嘛会有这个link错误。=_=|| AppTester.obj : error LNK2001: unresolved external symbol "protected: __thiscall ObjCounter<class TestApp>::ObjCounter<class TestApp>(void)" (??0?$ObjCounter@VTestApp@@@@IAE@XZ) Debug/test.exe : fatal error LNK1120: 1 unresolved externals
oN5GrzoN 2014-02-13
  • 打赏
  • 举报
回复
class TestApp : private ObjCounter<TestApp>
这么厉害?
oN5GrzoN 2014-02-13
  • 打赏
  • 举报
回复
啥编译器?error号是多少

15,440

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧