Path: utzoo!attcan!uunet!cs.utexas.edu!swrinde!ucsd!ucbvax!zardoz.coral.com!don From: don@zardoz.coral.com (Don Dewar) Newsgroups: comp.lang.c++ Subject: call a constructor Message-ID: <9008031721.AA18726@zardoz.coral.com> Date: 3 Aug 90 17:21:49 GMT References: <1990Aug1.182945.23905@dg-rtp.dg.com> Sender: daemon@ucbvax.BERKELEY.EDU Lines: 46 ) Return-Path: ) Date: 1 Aug 90 18:29:45 GMT ) From: uunet!mcnc.org!rti!dg-rtp!farm!taylor (William Taylor) ) Organization: Data General Corp., Research Triangle Park, NC ) Subject: call a constructor ) Sender: uunet!prep.ai.mit.edu!info-g++-request ) To: info-g++@prep.ai.mit.edu ) ) Using g++: ) ) I would like to call a constructor directly on a piece of memory that ) I have allocated. ) ) I have a pointer to some memory (malloc'ed, shared memory, ...) ) and I would like to put a class there. How can I call the constructor ) for that class (and its base and member classes, etc.) to initialize ) the memory? ) ) I have found out how to do it with cfront. You can specify a second ) argument to "new" telling it where to construct the class - just what I wanted. ) ) Is there any way to do this with g++? ) ) William Taylor taylor@dg-rtp.dg.com ) Data General Corporation {world}!mcnc!rti!dg-rtp!taylor ) Research Triangle Park, NC 27709 (919) 248-5801 ) ) I have also been wondering this same thing. Something I used to do with CFront all the time was call one constructor from another as a convenient way to build up overloaded constructors. Now, to do the same thing I have to separate the code out of the constructor and call call it from each constructor. Is there any chance this will change? +---------+ | Coral | |@@@@@*@**| |@@*@@**@@| Don Dewar |*@@**@@@@| Coral Network Corporation, Marlborough, MA |@***@@@@@| Internet: don@coral.com |@@**@@@@@| Phone: (508) 460-6010 |*********| Fax: (508) 481-6258 |Networks | +---------+