Article View: rec.games.programmer
Article #2037Re: Should I learn C or C++ first?
From: Rainer Deyke
Date: Fri, 01 Sep 1995 12:57
Date: Fri, 01 Sep 1995 12:57
42 lines
2444 bytes
2444 bytes
Darren Walker (dwalker@imtn.dsccc.com) wrote: : Rainer Deyke (rainer@deyke3.fc.hp.com) wrote: : : Obviously when using an array where each object is initialized to a : : different value. Especially a resizable array. : Um, I still think you are missing the point behind new and delete, but you : are set in your ways, so malloc and remalloc to your hearts content. We : can't stop you. But I'll attempt one last time anyway... : In the case of a pointer to a dynamic array, you could simply do (using a : dynamic array class called dynArray) : dynArray* dynamicArray; : dynamicArray = new dynArray; // call the default or redefined : // default constructor : ...then anytime you need to change the array, you can do this... : dynamicArray->resizeArray(NEW_SIZE); : or... : dynamicArray->addElement(ELEMENT); : or something like that...you could of course have used malloc instead... So how do you implement dynamicArray without realloc? And how can you have dynamic arrays of any arbitrary element type (dynamic array of dynamic arrays, dynamic arrays of function pointers, etc.)? : the whole point is that you don't HAVE to use new and delete, they are merely : _convenient_ overloadable operators, just like you may not want to use cout : or cin for favor of a faster printf or fprintf. But like any feature, unless : you use it, you have no idea how nice it really is... Of course I don't have to use them, and I don't use them. So, is there any remaining advantage to using C++ (other than inline functions)? -- +----------------------------------------------+ | Rainer Deyke (rainer@mdddhd.fc.hp.com) | | "The Earth shall inherit the meek" - Carcass | +----------------------------------------------+
Technical Details
Message-ID:
<42700d$gmm@deyke3.fc.hp.com>Path:
arc1-ca.pugleaf.net!fc.hp.com!hpfcmdd!deyke3!rainerReferences:
<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> <41v8k9$jq8@tpd.dsccc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fc.hp.com!hpfcmdd!deyke3!rainer From: rainer@deyke3.fc.hp.com (Rainer Deyke) Newsgroups: rec.games.programmer,comp.lang.c++ Subject: Re: Should I learn C or C++ first? Followup-To: rec.games.programmer,comp.lang.c++ Date: 1 Sep 1995 12:57:49 GMT Organization: my basement Message-ID: <42700d$gmm@deyke3.fc.hp.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> <41v8k9$jq8@tpd.dsccc.com> Reply-To: rainer@mdddhd.fc.hp.com NNTP-Posting-Host: deyke3.fc.hp.com X-Newsreader: TIN [version 1.2 051093BETA PL3]