64,637
社区成员
发帖
与我相关
我的任务
分享
class A
{
public:
int * m_pi;
A()
{
m_pi = new int;
}
~A()
{
delete m_pi;
m_pi = 0;
}
void clean()
{
delete m_pi;
m_pi = 0;
}
};
int main()
{
A* pa=new A();
pa->clean(); //m_pi = 0;
delete pa; //m_pi 未定义。
pa = NULL;
return 0;
}
class CEngineApp
{
public:
CEngineApp();
~CEngineApp();
public:
CFlashDlg * m_pFlashDlg;
};
CEngineApp::CEngineApp()
,m_pFlashDlg(NULL)
{
}
CEngineApp::~CEngineApp()
{
//delete m_pFlashDlg;
//m_pFlashDlg = NULL;
}
class CFlashDlg
{
public:
CFlashDlg();
virtual ~CFlashDlg(){}
void DlgCreateWindow(WNDPROC lpfnWndProc);
LRESULT ThreadProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp);
protected:
CFlash * m_pflash;
};
void CFlashDlg::DlgCreateWindow(WNDPROC lpfnWndProc)
{
//create windows
//....
MSG msg;
ZeroMemory(&msg,sizeof(MSG));
while(msg.message != WM_QUIT)
{
if(GetMessage(&msg,NULL,0U,0U))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if ( m_pflash != 0)
m_pflash->Update();
}
}
}
LRESULT CFlashDlg::ThreadProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp)
{
PAINTSTRUCT ps;
HDC hdc;
int wmId, wmEvent;
UINT ev = (UINT) wp;
switch(msg)
{
case WM_CLOSE:
if ( m_pflash != 0)
{
m_pflash->Stop();
delete m_pflash;
m_pflash = 0;
}
DestroyWindow(m_hWnd);
break;
default:
return DefWindowProc(hWnd, msg, wp, lp);
}
return DefWindowProc(hWnd,msg,wp,lp);
}