Mfc 我需要在CFont上调用DeleteObject吗

Mfc 我需要在CFont上调用DeleteObject吗,mfc,Mfc,我想知道,在以下情况下是否需要调用DeleteObject CFont* oldFont = label.GetFont(); LOGFONT oldLogFont; oldFont->GetLogFont(&oldLogFont); oldLogFont.lfWeight = FW_BOLD; CFont newFont; newFont.CreateFontIndirectW(&oldLogFont); label.SetFont(&newFont, true)

我想知道,在以下情况下是否需要调用DeleteObject

CFont* oldFont = label.GetFont();
LOGFONT oldLogFont;
oldFont->GetLogFont(&oldLogFont);
oldLogFont.lfWeight = FW_BOLD;
CFont newFont;
newFont.CreateFontIndirectW(&oldLogFont);
label.SetFont(&newFont, true);
// Do I need to call oldFont->DeleteObject() or newFont->DeleteObject()?

谢谢。

不,你不需要。MFC类是类。当对象退出范围(即被解构)时,对象将被适当删除