类的继承引起的一个错误:error C2259 cannot instantiate abstract class due to following members
来源:互联网 发布:ios知乎日报 api 编辑:程序博客网 时间:2024/04/30 06:04
错误描述:
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观念和抽象类和接口)
- 类的继承引起的一个错误:error C2259 cannot instantiate abstract class due to following members
- 类的继承引起的一个错误:error C2259 cannot instantiate abstract class due to following members
- 提示"cannot instantiate abstract class due to following members"?
- 提示"cannot instantiate abstract class due to following members"? .
- c++中的纯虚函数和提示"cannot instantiate abstract class due to following members"
- error C2259: 'CException' : cannot instantiate abstract class
- error C2259: 'CException' : cannot instantiate abstract class 2011.11.04
- CLSID {10020200-E260-11CF-AE68-00AA004A34D5} failed due to the following error: 80040154. 错误的解决办法
- Pointers to Class Members:指向类成员的指针
- 指向类成员的指针 (pointers to class members)
- 指向类成员的指针(Pointers to Class Members)
- Jira plugin cannot startup due to "Error parsing class file"
- Error 2259 : cannot instantiate abstract class with one or more pure virtual functions
- 抽象类(abstract class)的继承
- Retrieving the COM class factory for component with CLSID {xxxx} failed due to the following error:
- spring Unable to instantiate Action一个很伤心的错误!
- "Cannot instantiate QtProjectEngine object"错误的解决方法
- 错误:error C2259:“CxxDlg”:不能实例化抽象类
- 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 '' 中的标识列插入显式值。
- c语言malloc和calloc使用心得
- 认识大家
- cisco交换机配置
- tomcat6+spring2.5+xfire1.2开发webservice报错原因
- 类的继承引起的一个错误:error C2259 cannot instantiate abstract class due to following members
- 大白菜 U盘系统指南
- CSS 基本选择器
- WinCE开始菜单定制(二)
- 从“土豆”看软件**
- RMI 远程对象工程设计模式
- MFC 分页控件
- C++ primer 注意的知识点(第3-6章)
- asp.net wap