After I release the document from memeory, I forget to set NULL to the document pointer. Then later when trying to do dynamic_cast, above dialog pops up.

But It's not proved true by below code:

{

CTestSub* pSub = new CTestSub();

 delete pSub;

 /*pSub = NULL;*/ // comment it.

 CTestParent* pParent = dynamic_cast<CTestParent*>(pSub);

}

After executing above code, no such dialog pops up. It's reasonable in this case because although the memory is released, but the memory area can still be treated a CTestSub object occupied it. Definitely, casting it to its parent class is correct.


Note here, keeping on learning.