🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #2019

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

#2019
From: Pete Becker
Date: Tue, 29 Aug 1995 18:15
36 lines
1997 bytes
In article <41tjep$2hn@deyke3.fc.hp.com>, rainer@deyke3.fc.hp.com says...
>
>Pete Becker (pete@borland.com) wrote:
>: In article <41kici$p4t@deyke3.fc.hp.com>, rainer@deyke3.fc.hp.com says...
>: >: 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.
>
>Real programmers don't "accidentally" forget to initialize objects.
>

Real programmers are human and make mistakes.

>:       Or, to turn the question around the other way, why separate them?
>
>Obviously when using an array where each object is initialized to a
>different value.  Especially a resizable array.

That's not the example you posted, which allocated a single object. So, let me 
ask again: in the code you posted, what benefit is there in separating 
allocation from initialization?
Technical Details
Message-ID: <41vlgv$q33@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> <41ngln$qau@druid.borland.com> <41tjep$2hn@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: 29 Aug 1995 18:15:59 GMT
Organization: Borland International
Message-ID: <41vlgv$q33@druid.borland.com>
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41afe9$d10@newsbf02.news.aol.com> <41kici$p4t@deyke3.fc.hp.com> <41ngln$qau@druid.borland.com> <41tjep$2hn@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