错误描述:
e:/mywork/1.7sp1/ginfo/client/src/skdesigner/dsgquerydlg.h(295) : error C2259: 'CDsgFormatDataMgrDlg' : cannot instantiate abstract class due to following members:
e:/mywork/1.7sp1/ginfo/client/src/skdesigner/dsgformatdatamgrdlg.h(14) : see declaration of 'CDsgFormatDataMgrDlg'
错误原因:
一个实现类继承了一个抽象基类,但是却没有把抽象基类中的方法全部实现。
可以类似的实现:
virtual void EnableControl(PSKOPEROBJECT lpoo, BOOL bEnable) {}//这些是用不到的抽象基类中的方法,也要实现
代码实例:
class CDsgFormatDataMgrDlg : public CDialogImpl<CDsgFormatDataMgrDlg>,
public ISkBusinessEngineSink //抽象基类
{
public:
enum {IDD = IDD_FORMATDATAMGR_DLG};
CDsgFormatDataMgrDlg();
virtual ~CDsgFormatDataMgrDlg();
virtual BOOL PreTranslateMessage(MSG* pMsg);
...
}
class ISkBusinessEngineSink
{
public:
virtual void HandleOneCSObject(LPCTSTR lpszName) {}
virtual BOOL HandleUpdateCalendarResult(int nType, PCALENDAREVENT lpce,
DWORD dwClientTmpId, BOOL bRet, DWORD dwErrorCode) { return FALSE; }
virtual BOOL HandleUpdateDesktopResult(int nType, PDESKTOPITEM lpdi,
DWORD dwClientTmpId, BOOL bRet, DWORD dwErrorCode) = 0;
virtual void HandleHotBUList(PHOTBU lphb, int nCount) {}
virtual void OnDBFuncReady(BOOL bReady) = 0;
virtual void OnDBViewReady(BOOL bReady) = 0;
virtual void OnSNReady(BOOL bReady) = 0;
virtual void OnTableReady(BOOL bReady) = 0;
...
}
抽象基类中的方法必须完全实现...
附录:
http://www.cnblogs.com/shenfx318/archive/2007/01/25/630760.html(抽象基类和接口的选择和区别)
http://www.cnblogs.com/TravelingLight/archive/2010/06/02/1750073.html(抽象基类的一些问题)
http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Companion/cxx_crib/interfaces.html
(OO观念和抽象类和接口)