home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18217 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.6 KB  |  36 lines

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