一个具有对象计数功能的基类

时间:2012-08-18 05:33:30
【文件属性】:
文件名称:一个具有对象计数功能的基类
文件大小:8KB
文件格式:RAR
更新时间:2012-08-18 05:33:30
计数 基类 模板 effective C++ More Effective C++的Item M26:限制某个类所能产生的对象数量,里面有一个模板类可作为基类,可作为参考学习内容,如果使用VS2005对模板类进行编译,注意类声明和定义如果分开写在.h和.cpp,子类不能只#include "Counted.h",否则会导致Link时发生Build error: Printer.obj : error LNK2019: unresolved external symbol "protected: __thiscall Counted::Counted(void)" ([email=??0?$Counted@VPrinter@@@@IAE@XZ]??0?$Counted@VPrinter@@@@IAE@XZ[/email]) referenced in function "private: __thiscall Printer::Printer(void)" ([email=??0Printer@@AAE@XZ]??0Printer@@AAE@XZ[/email]) 很多编译器对模板类的声明和定义分开写支持不完善,把定义也写在.h可以解决,或者子类include时包含.cpp等。
【文件预览】:
TestSigClass
----TestSigClass.suo(12KB)
----TestSigClass()
--------stdafx.cpp(299B)
--------TestSigClass.vcproj(5KB)
--------stdafx.h(516B)
--------Counted.cpp(43B)
--------Pen.cpp(277B)
--------TestSigClass.cpp(3KB)
--------Counted.h(866B)
--------Printer.h(499B)
--------Printer.cpp(349B)
--------Pen.h(438B)
--------TestSigClass.vcproj.HUANGJIAFA.Administrator.user(1KB)
--------ReadMe.txt(1KB)
----TestSigClass.sln(901B)

网友评论