home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!spool.mu.edu!sdd.hp.com!ux1.cso.uiuc.edu!m.cs.uiuc.edu!sunb10.cs.uiuc.edu!sparc10.cs.uiuc.edu!pjl
- From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
- Subject: Re: help
- Message-ID: <1992Sep14.022715.1460@sunb10.cs.uiuc.edu>
- Sender: news@sunb10.cs.uiuc.edu
- Organization: University of Illinois at Urbana-Champaign
- References: <1992Sep13.164046.24676@njitgw.njit.edu>
- Distribution: usa
- Date: Mon, 14 Sep 1992 02:27:15 GMT
- Lines: 31
-
- In <1992Sep13.164046.24676@njitgw.njit.edu> jxd7299@hertz.njit.edu (Jing X Ding) writes:
-
-
- > PROD *A;//PROD is a defined class
- > :
- > :
- > for (...){
- > A=(PROD*)new char [totalprod*sizeof(PROD)];//totalprod is a const
- > :
- > :
- > Place 1
- > }
- > Place 2
-
- >The problem is :(1) Where can I use destructure to free memory (Place 1 or
- >Place 2)? (2) How to write the destructure?
-
- *****> new is not malloc; you don't calculate the size nor cast.
-
- for (...) {
- A = new PROD[ totalprod ];
- // ...
- delete[] A;
- }
-
- I suggest reading the relevant section on new/delete in a C++
- book.
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-