tags:

views:

11

answers:

1

I was wondering, do I need to call DeleteObject in the following case?

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()?

Thanks.

+1  A: 

No you don't. MFC classes are RAII classes. When the object drops out of scope (ie gets decosntructed) the object will be deleted appropriately.

Goz