🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #2044

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

#2044
From: Eric Gunnerson
Date: Tue, 05 Sep 1995 20:24
27 lines
1866 bytes
In article <425akd$4r7@status.gen.nz>, sarge@iconz.co.nz says...
>
>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.
>
The third point is that with new, you can define your own allocators on a per-class basis, so 
that you can optimized your memory allocation scheme (can you say cache?) without modifying the 
code that uses a class. 





-- 
The opinions expressed in this message are my own personal views 
and do not reflect the official views of Microsoft Corporation.
Technical Details
Message-ID: <42ibl0$kfq@news2100.microsoft.com>
Path: arc1-ca.pugleaf.net!news.microsoft.com!news
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> <425akd$4r7@status.gen.nz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.microsoft.com!news
From: ericgu@microsoft.com (Eric Gunnerson)
Newsgroups: rec.games.programmer,comp.lang.c++
Subject: Re: cout vs printf speed (was: Should I learn C or C++ first?)
Date: 5 Sep 1995 20:24:00 GMT
Organization: Microsoft Corporation
Message-ID: <42ibl0$kfq@news2100.microsoft.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> <41vst0$9nb@gap.cco.caltech.edu> <tgooding-3008950016040001@helser196.res.iastate.edu> <809779542snz@onex.demon.co.uk> <425akd$4r7@status.gen.nz>
NNTP-Posting-Host: 157.55.67.107
Mime-Version: 1.0
X-Newsreader: WinVN 0.93.14