dll导出类中有回调函数


这个问题我弄了一下午,看似很简单,可是一直没搞定

.h头文件

   
  typedef  int (__stdcall *CallbackFunction)(int nValue);
  

class __declspec(dllexport) CXXX
{
public:
XStitching( void );

~XStitching(void);
private:
CallbackFunction m_callback;
};

.cpp文件

   
  CXXX::CXXX()
  
{
m_callback = NULL;
}

CXXX::~CXXX()
{
if(m_callback != NULL)
m_callback = NULL;

}

以上的类封装在dll中,外部调用如下:

   
  CXXX *cls=new CXXX();
  
delete cls;

这时候就会报错:
HEAP CORRUPTION DETECTED:after Normal block(#354)at 0x0015f148
CRT detected that the application wrote to memory after end of heap buffer.

就这么点程序我死活想不明白哪里溢出了,请高人指教

dll C++

无聊zhi极 10 years, 7 months ago

Your Answer