I have a class (Event.h):
class CEvent
{
publi开发者_高级运维c:
CEvent();
~CEvent();
int nVal;
};
defined in Event.cpp
#include "event.h"
CEvent::CEvent() {}
CEvent::~CEvent() {}
In a different class I have included "event.h" and am trying the following:
CEvent* pEvent = new CEvent();
But Im getting a compiler error:
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
What am I doing wrong? This is something truly trivial and Im too close to see it.
Using VC 2008.. fwiw..
CEvent is also the name of a class in MFC. I would rename the class to prevent confusion.
Found the problem:
#ifdef _DEBUG
#define DEBUG_NEW
#endif
was included in a different class. This was impacting 'new' everywhere! Commenting this out clears the error.
Go figure.
精彩评论