🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #2030

Re: cout vs printf speed (was: Should I learn C or C++ first?)

#2030
From: Edward Sargisson
Date: Thu, 31 Aug 1995 21:46
13 lines
1366 bytes
In article <809779542snz@onex.demon.co.uk>, Martin@onex.demon.co.uk says...
>
>OK, here's a new one to throw into this thread - but not totally un-related.
>Which is faster new or malloc ? My C++ book says that new should be faster.

More to the point is the fact that you shouldn't ever use malloc for 
user-defined types.  The reason is that new will call constructors (and 
delete will call destructors).  malloc() is okay for built-in types but don't 
use it otherwise.  
The second point is that new is type safe.  malloc() returns a void * which 
you then have to cast (except you don't => big hole in typing system).

In conclusion don't use malloc.
Technical Details
Message-ID: <425akd$4r7@status.gen.nz>
Path: arc1-ca.pugleaf.net!status.gen.nz!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> <41v8k9$jq8@tpd.dsccc.com> <41vst0$9nb@gap.cco.caltech.edu> <tgooding-3008950016040001@helser196.res.iastate.edu> <809779542snz@onex.demon.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!status.gen.nz!usenet
From: sarge@iconz.co.nz (Edward Sargisson)
Newsgroups: rec.games.programmer,comp.lang.c++
Subject: Re: cout vs printf speed (was: Should I learn C or C++ first?)
Date: 31 Aug 1995 21:46:53 GMT
Organization: Internet Company of New Zealand
Message-ID: <425akd$4r7@status.gen.nz>
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> <41vst0$9nb@gap.cco.caltech.edu> <tgooding-3008950016040001@helser196.res.iastate.edu> <809779542snz@onex.demon.co.uk>
NNTP-Posting-Host: 202.37.141.177
X-Newsreader: WinVN 0.99.6