home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:16359 comp.lang.c:16598
- Path: sparky!uunet!dtix!darwin.sura.net!Sirius.dfn.de!solaris.rz.tu-clausthal.de!news!andreas
- From: andreas@appel012.hydromech.uni-hannover.de (Andreas Dunker)
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: Delete a dynamically allocated 2-dim'l array?
- Message-ID: <1992Nov16.142710.17104@newsserver.rrzn.uni-hannover.de>
- Date: 16 Nov 92 14:27:10 GMT
- References: <BxM7EC.BvE@math.uwaterloo.ca>
- Sender: news@newsserver.rrzn.uni-hannover.de (News Service)
- Organization: RRZN
- Lines: 36
- X-Newsreader: Tin 1.1 PL4
-
- xjzhu@math.uwaterloo.ca (Xiaojun Zhu) writes:
- :
- : Q: How to delete a dynamically allocated 2-dimensional array?
- :
- : More specifically, I have:
- :
- : int row, column;
- : int **array;
- :
- [ deleted ]
- :
- : Can I simply say:
- :
- : delete array;
- :
-
- You only have "free'd" the pointer to th array of pointers,
- but the memory is still allocated.
-
- : Or should I say:
- :
- : for(i=row-1; i>=0; i--)
- : delete array[i];
- : delete array;
- :
-
- This is the right way.
-
- ______________________________________________________________________________
-
- Andreas Dunker Institut fuer Stroemungsmechanik
- andreas@appel012.hydromech.uni-hannover.de und elektronisches Rechnen
- im Bauwesen
- Universitaet Hannover
- 2B | ! 2B (W. Shakespeare) West Germany
- ______________________________________________________________________________
-