new/delete
1 messages in this thread
Hi Yutaka,
> become confused of new/delete on pointers to the class derived from
> CFrameWnd;
I think MFC Tech. Notes #17 will answer these questions more clearly on
how to destroy Window objects.
> another question: I used Class Wizard to create CMyFrameWnd, the
> resulting constructor and destructor were declared as protected member
> functions; consequently, I couldn't use new and delete operators (I
> manually changed the declaration to 'public' to be able to continue my
> coding). this confused me because according to the MFC Reference
> Volume 1 (p. 446): "Before you call either Create or LoadFrame, you
> MUST construct the framewindow object on the heap using the C++ new
> operator…" with a protected constructor, how can I use new?
With a protected constructor, it's meant only to be constructed via a
member function or friends of the class, or member functions or friends
of its derived class. However, I don't see any problems with you
manually changing it to public. I believe it was meant to be protected
for two reasons. One, for dynamically creation and two for derived
classes only.
Sincerely,
Brian Ku
-Microsoft Developer Support