关于异常处理的困惑,详情请进。
CList::CList()
{
m_nCount = 0;
m_pHeader = (CShape**)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CShape*)*5);
}
CList::~CList()
{
HeapFree(GetProcessHeap(), 0, m_pHeader);
}
void CList::AddTail(CShape *pItem)
{
__try
{
m_pHeader[m_nCount] = pItem;
//m_nCount > 5,此句仍能执行成功。
}
__except(EXCEPTION_CONTINUE_EXECUTION)
{//此块的内容从来不被执行
m_pHeader = (CShape**)HeapReAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,m_pHeader,sizeof(CShape*)*5);
}
m_nCount++;
}
CShape* CList::GetItem(int i)
{
if( i > m_nCount) return NULL;
return m_pHeader[i];
}
为什么不会产生异常,是不是HeapAlloc的问题?