🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3612

delete or delete[] ???

#3612
From: David Sachs
Date: Thu, 07 Mar 1996 23:22
25 lines
1732 bytes
Should delete or delete[] be used for a pointer to an array type?

// 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;
delete[] b2; // or should it be delete   b2;
-- 
***** Listen Americans, the IRS is your taxer,  the IRS is one. *****
David Sachs - Fermilab, HPPC MS369 - P. O. Box 500 - Batavia, IL 60510
Voice: 1 708 840 3942      Deparment Fax: 1 708 840 3785
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]
Technical Details
Message-ID: <4hnqvf$mgr@fsgi01.fnal.gov>
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
From: b91926@fsgi01.fnal.gov (David Sachs)
Newsgroups: comp.std.c++
Subject: delete or delete[] ???
Date: 07 Mar 1996 15:22:36 PST
Organization: FERMILAB, Batavia, IL
Approved: austern@isolde.mti.sgi.com
Message-ID: <4hnqvf$mgr@fsgi01.fnal.gov>
Reply-To: sachs@fnal.fnal.gov
NNTP-Posting-Host: isolde.mti.sgi.com
Summary: Is delete or delete[] correct in certain cases?
Keywords: delete
X-Original-Date: 7 Mar 1996 17:20:15 -0600
X-Newsreader: NN version 6.5.0 #9 (NOV)
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMT9vy0y4NqrwXLNJAQGTSQH+N6FqNwvxag/xlmaCd9u9A8SzjXYxE/8i
 T0Uta+aN6Q06r7fAGX2fvzO9kFN+reaTepJ3M/hUeMDoDCqlo0Voxw==
 =41JG
Originator: austern@isolde.mti.sgi.com