Article View: rec.games.programmer
Article #2042Re: cout vs printf speed (was: Should I learn C or C++ first?)
From: Hans Bos
Date: Mon, 04 Sep 1995 15:50
Date: Mon, 04 Sep 1995 15:50
40 lines
1981 bytes
1981 bytes
dqua@earthlink.net (Derick J.R. Qua-Gonzalez) writes: >akemi@netcom.com (David Boeren) writes: >>Well, there's only one problem I can think of. There is no "renew" analagous >>to the realloc() function. >What realloc() does is change the size of an allocated block of memory. >The question is, what would it mean to "renew" an object? You cannot >change an individual object's size. As far as an array of objects is >concerned, if you want a resizable array, it is better to use a container >class specifically designed for this purpose. So what would the semantics >and use of "renew" be? If the new array is allocated on a different address, the copy constructor function of all "moved" objects should be called to move the object. If the new size is smaller then the old one the destructor functions should be called for all objects that are not within the new range. If the new size is larger then the old one the (default) constructor function should be called for the new objects. This can be optimized (by the compiler) if the class doesn't have (copy) constructors or destructors. E.G. for an array of pointers renew is the same is realloc. A container class could use renew to implement an array (template) class which is fast for simple types, but correct (e.g. all constructors etc. are called) for more complex types. Greetings, Hans Bos \\ \\// Hans Bos PO-Box 88 email: Hans.Bos@xelion.nl //\\ Xelion b.v. 2600 AB Delft tel: (31)15 - 62 21 21 // The Netherlands fax: (31)15 - 52 17 60
Technical Details
Message-ID:
<DEE1Br.7xF@xelion.nl>Path:
arc1-ca.pugleaf.net!EU.net!sun4nl!xelion!hansReferences:
<809779542snz@onex.demon.co.uk> <809810607snz@senator.demon.co.uk> <akemiDE6nJo.4u@netcom.com> <dqua.810095515@dqua>Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer,comp.lang.c++ Path: arc1-ca.pugleaf.net!EU.net!sun4nl!xelion!hans From: hans@xelion.nl (Hans Bos) Subject: Re: cout vs printf speed (was: Should I learn C or C++ first?) Message-ID: <DEE1Br.7xF@xelion.nl> Organization: Xelion bv References: <809779542snz@onex.demon.co.uk> <809810607snz@senator.demon.co.uk> <akemiDE6nJo.4u@netcom.com> <dqua.810095515@dqua> Date: Mon, 4 Sep 1995 15:50:15 GMT