🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #411

Re: Question about pointers in c++

#411
From: Martijn Lievaart
Date: Wed, 18 Feb 1998 00:00
25 lines
1865 bytes
William A. McKee wrote in message <01bd38f4$2d5edfd0$5263bdcd@tom>...
[snip]
>There is one case not covered above (a not so rare exception):
>
>void f() {
> CWnd * wnd = new CWnd;
> wnd -> Create (...);
>...
> wnd -> DestroyWindow ();
> // do not delete wnd; because it is deleted in DestroyWindow!
> // moral: RTFM.
>}
>

You're right. It is ofcourse actually a variant of case 3 (see original
post), only the delete call is now in a member instead of main program flow.
It is something that may confuse newbies to no end, so it's good you mention
it.

BTW, exactly the same can be achieved by "delete wnd" instead of
"wnd->DestroyWindow()". I personally find this much clearer.

Greetz
Martijn (mlievaar(at)orion(dot)nl)
Technical Details
Message-ID: <6cendj$ibc$1@news2.xs4all.nl>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <MPG.f4db3e9eeb97b39896ab@news.edmonton.telusplanet.net> <6c1628$lmg$1@news2.xs4all.nl> <01bd38f4$2d5edfd0$5263bdcd@tom>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f8d38,4e3e5791e6083a64
X-Google-Attributes: gidf8d38,public
X-Google-Thread: 109fba,4e3e5791e6083a64
X-Google-Attributes: gid109fba,public
X-Google-Thread: 108ebe,4e3e5791e6083a64
X-Google-Attributes: gid108ebe,public
X-Google-Thread: 114592,4e3e5791e6083a64
X-Google-Attributes: gid114592,public
X-Google-Thread: 103bde,4e3e5791e6083a64
X-Google-Attributes: gid103bde,public
From: "Martijn Lievaart" <mlievaar@orion.nl>
Subject: Re: Question about pointers in c++
Date: 1998/02/18
Message-ID: <6cendj$ibc$1@news2.xs4all.nl>
X-Deja-AN: 326209497
Sender: martijnl@ois.orion.nl
References: <MPG.f4db3e9eeb97b39896ab@news.edmonton.telusplanet.net> <6c1628$lmg$1@news2.xs4all.nl> <01bd38f4$2d5edfd0$5263bdcd@tom>
X-XS4ALL-User: martijnl@xs4all.nl on ois.orion.nl
X-XS4ALL-Date: Wed, 18 Feb 1998 14:24:03 CET
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Organization: XS4ALL, networking for the masses
Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.language,borland.public.cpp.owl,borland.public.cpp.winapi,comp.lang.c++