Article View: comp.std.c++
Article #3630Re: delete or delete[] ???
From: Fergus Henderson
Date: Sat, 09 Mar 1996 05:55
Date: Sat, 09 Mar 1996 05:55
37 lines
1854 bytes
1854 bytes
b91926@fsgi01.fnal.gov (David Sachs) writes: >Should delete or delete[] be used for a pointer to an array type? `delete[]' should be used. See 5.3.5[expr.delete]/2, which says (amoung other things) that the syntax of the delete expression must match the *type* of the corresponding new expression, not its *syntax*. >// It is assumed that some_type is an existing type >typedef some_type array_type[10]; > >array_type* a1 = new array_type[5]; >array_type* b1 = new some_type[5][10]; >array_type* a2 = new array_type; >array_type* b2 = new some_type[10]; >... >delete[] a1; >delete[] b1; >delete a2; // or should it be delete[] a2; Yes, it should be `delete[] a2;'. >delete[] b2; // or should it be delete b2; Nope, that one is correct. -- Fergus Henderson WWW: http://www.cs.mu.oz.au/~fjh fjh@cs.mu.oz.au PGP: finger fjh@128.250.37.3 --- [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Technical Details
Message-ID:
<4hr3tl$b53@mulga.cs.mu.OZ.AU>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backReferences:
<4hnqvf$mgr@fsgi01.fnal.gov>Show Full Headers
Complete Article Headers
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson) Message-ID: <4hr3tl$b53@mulga.cs.mu.OZ.AU> X-Original-Date: 9 Mar 1996 05:11:17 GMT Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 09 Mar 96 05:55:44 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: Re: delete or delete[] ??? Organization: Comp Sci, University of Melbourne References: <4hnqvf$mgr@fsgi01.fnal.gov> Keywords: delete X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMUEdd+EDnX0m9pzZAQEWSAGAnx5lH44n7vkk1u+sF62/TECUZ0lnP7v+ qymn/TUbeazppk+5LnIcvUmZpuoH+C5m =xrIY