在类函数中判断当前对象是否有效.
#ifdef _DEBUG
#include <windows.h>
#define ASSERT_READ assert(!::IsBadReadPtr(this, sizeof(*this)));
#define ASSERT_WRITE assert(!::IsBadWritePtr(this, sizeof(*this)));
#else
#define ASSERT_READ
#define ASSERT_WRITE
#endif
void CClass::testNullPointer(int n)
{
ASSERT_READ;
//ASSERT_WRITE;
//...
}