Article View: hepnet.lang.c++
Article #2Re: dynamicaly allocating a two dim. array
From: Sam Denton
Date: Tue, 10 Oct 1995 00:07
Date: Tue, 10 Oct 1995 00:07
18 lines
1063 bytes
1063 bytes
btrojano@chat.carleton.ca (Bart Trojanowski) revealed:
|for (a=0;a<x;x++)
--------------^ I assume you mean "a"
| delete array[a];
|delete *array;
|how come this works in dos and under windows it gives me a funkey
|protection fault.
Because you have an incorrect program. Note that your second delete
is deleting whatever the first element of array is pointing to, not
array itself. So you are deleting one thing twice and the other not
at all. (Also, you aren't using the correct form of delete here.)
Try this:
for (a=0;a<x;a++)
delete [] array[a];
delete [] array;
Technical Details
Message-ID:
<45cd7h$jrh@consolidated.ccinet.net>Path:
arc1-ca.pugleaf.net!consolidated.ccinet.net!usenetReferences:
<DG7ExA.3CG@cunews.carleton.ca>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!consolidated.ccinet.net!usenet From: std@maryville.com (Sam Denton) Newsgroups: hepnet.lang.c++,comp.lang.c,comp.lang.c++,cern.c++ Subject: Re: dynamicaly allocating a two dim. array Date: Tue, 10 Oct 1995 00:07:38 GMT Organization: Consolidated Communications Incorporated Message-ID: <45cd7h$jrh@consolidated.ccinet.net> References: <DG7ExA.3CG@cunews.carleton.ca> NNTP-Posting-Host: gate.maryville.com X-Newsreader: Forte Free Agent 1.0.82