关于内存泄漏有一问,问题其实很土!
最近在看到《深入浅出mfc》时看到候先生的例子scribble中,有这么一个函数
CStroke* CScribbleDoc::NewStroke()
{
CStroke* pStrokeItem = new CStroke(m_nPenWidth);
m_strokeList.AddTail(pStrokeItem);
SetModifiedFlag(); // Mark the document as having been modified, for
// purposes of confirming File Close.
return pStrokeItem;
}
这个地方我有点不明白,为什么他new了一个CStroke对象,在程序中却没有delete它,但是事实上它并没有内存泄漏,但是我也是仿造它写的,我却提示有内存泄漏,大家能帮我讲解一下吗?谢谢!