Heap stack Class questons
I have the following confusions on Class creation. It appears
from macro expansion and stepping thru the framework calls
that the DocTemplate which holds the original Doc/View members
are created as nameless object instances referenced with a ptr
on the heap, correct ?
// eg:
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CFileHandlingDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CFileHandlingView));
AddDocTemplate(pDocTemplate);
// So if I derive a class as say,
MyClass::MFC_BaseClassWhatever
{ int Whatever = 1;
MyClass() {}
~MyClass() {}
};
// and then create an instance of it without using new as in,
MyClass MyClassObj;
// is MyClassObj here, created on the heap or the stack ?
// And what if I create the object as a member of a class
// already created on the heap as in,
class CFileHandlingDoc : public CDocument
{
protected:
CFileHandlingDoc();
DECLARE_DYNCREATE(CFileHandlingDoc)
MyClass MyClassObj;
///------rest of class
// is MyClassObj here, created on the heap or the stack ?
// And finally am I correct in ascertaining that as long as I don't
// actually create a class (or anything ) using
WhateverType* pWhatever = new WhateverType;
// then I don't have to worry about
delete pWhatever; // in the destructor or where ever
// correct ??