Re: C++

From: Erwin S. Andreasen (erwin@PIP.DKNET.DK)
Date: 12/08/97


On Mon, 8 Dec 1997, Akuma/Chris Baggett/DOOMer wrote:

> Ok, quick question, if i were to use [cm]alloc to CREATE()
> a char_data structure in C++, would it STILL do the constructor
> function char_data() even though i'm not using NEW ?

Nope, but if you absolutely want, you could use the placement-new operator
to take care of it (r5.3.3 in 2nd Edition of c++ programming language):

void *memory = calloc(sizeof(*ch),1);

Character *ch = new (memory) Character();

or such - AFAIR the parens after Character are necessary.

You will have to explicitly call your ~Character() after you are finished,
so this is quite a PITA.

However, if you said what it is you really want to do, perhaps we'd be of
more help. If it is some sort of memory tracking, it's probably done in an
operator new/delete in the class of which memory you want to track.



 =============================================================================
Erwin Andreasen   Herlev, Denmark <erwin@pip.dknet.dk>  UNIX System Programmer
<URL:http://www.abandoned.org/drylock/>     <*>         (not speaking for) DDE
 =============================================================================


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST