🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #2012

Re: Should I learn C or C++ first?

#2012
From: Pete Becker
Date: Sat, 26 Aug 1995 16:04
28 lines
1882 bytes
In article <41kici$p4t@deyke3.fc.hp.com>, rainer@deyke3.fc.hp.com says...
>
>P Moore906 (pmoore906@aol.com) wrote:
>: >Yes, but "variety of styles" may very well include using purely the C
>: >subset of C++.  Some C++ features are actually pretty stupid, like
>: >the 'new' and 'delete' operators that correspond to 'malloc' and
>: >'free' but lack anything corresponding to 'realloc'.
>: I don't know how you could call new and delete stupid.  Dynamically
>: allocating memory for a class and passing arguments to its constructors at
>: the same time would be impossible without new and delete!  How could you
>: ever say:
>
>: TApplication* MyApp;
>: MyApp = new TApplication("My Application");
>
>: without new and delete?
>
>Why bother with doing both at the same time?
>
>MyApp = (TApplication *)malloc(sizeof(TApplication));
>create_TApplication(MyApp, "My Application");

The difference is in the gap between the two lines, where you have something 
that claims to be a pointer to a TApplication object, but isn't. C++ makes it 
very hard to perform operations on objects that have not been initialized. 
Separating memory allocation from initalization makes it much easier to 
accidentally do things like this, as we have all done at one time or another.
	Or, to turn the question around the other way, why separate them?
Technical Details
Message-ID: <41ngln$qau@druid.borland.com>
Path: arc1-ca.pugleaf.net!druid.borland.com!usenet
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41afe9$d10@newsbf02.news.aol.com> <41kici$p4t@deyke3.fc.hp.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!druid.borland.com!usenet
From: pete@borland.com (Pete Becker)
Newsgroups: rec.games.programmer,comp.lang.c++
Subject: Re: Should I learn C or C++ first?
Date: 26 Aug 1995 16:04:07 GMT
Organization: Borland International
Message-ID: <41ngln$qau@druid.borland.com>
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41afe9$d10@newsbf02.news.aol.com> <41kici$p4t@deyke3.fc.hp.com>
NNTP-Posting-Host: sbcandau.borland.com
Mime-Version: 1.0
Content-Type: Text/Plain; charset=ISO-8859-1
X-Newsreader: WinVN 0.99.5