home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: malloc or new in c++
- Message-ID: <1992Sep10.170132.553@taumet.com>
- Organization: TauMetric Corporation
- References: <gate.8NagqB1w165w@toz.buffalo.ny.us> <6649@lhdsy1.lahabra.chevron.com>
- Date: Thu, 10 Sep 1992 17:01:32 GMT
- Lines: 22
-
- hwrvo@kato.lahabra.chevron.com (W.R. Volz) writes:
-
- |Let me get this straight: Are you saying that there is a problem of using
- |malloc in a c++ program? I realize that if I malloc some memory, then
- |I need to free it with free(). And if a create a new object with new, then I
- |delete with delete. I wouldn't 'free' an object allocated with 'new' and
- |'delete' an object allocated with 'malloc'. But if there is an incompatibility
- |in c++ between (malloc,free) and (new,delete), I don't know how one can mix
- |any program that uses both allocatation schemes.
-
- As long as you do what you have said here, there should be no problem.
- I don't know of a C++ implementation that won't allow malloc/free
- and new/delete in the same program. The C++ Standard will require
- that these be allowed to appear in the same program.
-
- You do have to be careful about not using malloc for an object with a
- constructor or destructor, and about not mixing styles on the same
- object.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-