home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!utcsri!torn!utzoo!censor!meadow!marc
- From: marc@meadow.uucp (Marc Riehm)
- Subject: overloading operator new
- Message-ID: <1992Dec18.125656.4293@meadow.uucp>
- Reply-To: marc@meadow.UUCP (Marc Riehm)
- Organization: Amdahl Canada Ltd., Software Development Center
- Date: Fri, 18 Dec 92 12:56:56 GMT
- Lines: 25
-
- I want to be able to take control of memory management in c++, and I've run
- into a problem with overloading operator new. I have c++ classes which
- provide memory "pool" management: these act as a layer over malloc(). What I
- want to do is to be able to specify which pool to allocate from when I
- instantiate an object of another class.
-
- Thus, say I had class MyObject -- I want to be able to instantiate instances
- of this class in some manner like...
- MyObject *myObj1 = new MyObject(bigHeap) where bigHeap is a memory pool, or
- MyObject *myObj2 = new MyObject(altHeap) etc.
- The store for myObj1 would come from bigHeap, and that for myObj2 from altHeap.
-
- My Turbo C++ 2.0 manual (the only C++ documentation I have available :( )
- says that the first argument of MyObject::new must be a size_t. i.e. we
- overload new via a method which looks like...
- void *MyObject::new(size_t)
- They imply that there can be other arguments to MyObject::new. Could anyone
- tell me whether or not this is true and, if it is, how to declare the method
- and how to use MyObject::new? Are there any side effects on the constructor?
-
- --
- Marc Riehm Amdahl Canada Ltd., Software Development Center
- 2000 Argentia Road, Plaza 2, Suite 300
- Mississauga, Ont. L5N 1V8
- marc@meadow.UUCP
-