home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18845 < prev    next >
Encoding:
Text File  |  1993-01-08  |  1.2 KB  |  40 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!howland.reston.ans.net!sol.ctr.columbia.edu!news.columbia.edu!cunixa.cc.columbia.edu!ae2
  3. From: ae2@cunixa.cc.columbia.edu (Amiran Eliashvili)
  4. Subject: using new
  5. Message-ID: <1993Jan8.171950.22884@news.columbia.edu>
  6. Sender: usenet@news.columbia.edu (The Network News)
  7. Nntp-Posting-Host: cunixa.cc.columbia.edu
  8. Reply-To: ae2@cunixa.cc.columbia.edu (Amiran Eliashvili)
  9. Organization: Columbia University
  10. Date: Fri, 8 Jan 1993 17:19:50 GMT
  11. Lines: 27
  12.  
  13.  
  14. Hi folks:
  15.  
  16.     I am in the process of porting a C program into C++ and
  17. learning a lot about C++. I am trying to find an equivalent C++
  18. construct for the following malloc command:
  19.  
  20.         
  21.     ptr = (TypeCast *) malloc( LENGTH(n));
  22.  
  23. where Length(n) is a macro that will return the n times of the
  24. desired object size. I have tried the following statement using new
  25. but for no avail:
  26.  
  27.  
  28.     ptr = (TypeCast *) new char(LENGTH(n));
  29.  
  30.  
  31. The statement with new operator does not deliver exactly what the
  32. malloc does. Any suggestions how to use new to get the same 'effect' as what the malloc does in statement a. Thanks much.
  33.  
  34.  
  35. Please reply to :
  36.  
  37. ae2@cunixa.cc.columbia.edu
  38.  
  39. /amiran
  40.