【发布时间】:2011-10-13 21:15:28
【问题描述】:
我有一堂课(Event.h):
class CEvent
{
public:
CEvent();
~CEvent();
int nVal;
};
在 Event.cpp 中定义
#include "event.h"
CEvent::CEvent() {}
CEvent::~CEvent() {}
在另一个类中,我包含了“event.h”并正在尝试以下操作:
CEvent* pEvent = new CEvent();
但是我得到一个编译器错误:
error C2440: 'initializing' : cannot convert from 'CEvent' to 'CEvent *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
我做错了什么?这真的是微不足道的事情,我太近了,看不到它。
使用 VC 2008..fwiw..
【问题讨论】:
-
我怀疑问题出在您没有向我们展示的某些代码中。
-
我想不出还有什么“有趣”的。它是 MFC 中基于对话框的应用程序。我必须有一些导致这种情况的编译器设置。我尝试创建其他标准对象并得到同样的错误。