【发布时间】:2011-04-13 12:19:14
【问题描述】:
我在头文件中有以下类
class CodeListSqlGenerator : public ICodeListSqlGenerator,public CDialog
{
........
public:
CodeListSqlGenerator(IIntelligentCodeListUpgraderParameter *i_intelligent_codelist_upgrader_parameter);
}
当我在 .cpp 文件中使用 new 运算符创建 CodeListSqlGenerator 类型的对象时
ICodeListSqlGenerator *CreateCodeListSqlGeneratorInterface(IIntelligentCodeListUpgraderParameter *i_intelligent_codelist_upgrader_parameter)
{
ICodeListSqlGenerator *i_codelist_sql_generator = new CodeListSqlGenerator(i_intelligent_codelist_upgrader_parameter);
return i_codelist_sql_generator;
}
当编译错误 C2661:'CObject::operator new':没有重载函数需要 4 个参数时,我得到以下信息 我该如何纠正这个错误? 在此先感谢-Athreya
【问题讨论】:
-
类层次结构中的构造函数定义是什么样的?此错误可能是由初始化程序列表中不正确的基本初始化引起的。
-
或者,更有可能的是,您正在使用 MFC 并且混淆了调试和非调试设置。
-
可能是 DEBUG_NEW 宏干扰了其他所有 new 定义。
-
如果你在导致错误的代码行之前写
#undef new,你是否仍然得到同样的错误?
标签: c++ mfc compiler-errors multiple-inheritance new-operator