Article View: comp.std.c++
Article #4128Re: auto_ptr problem?: delete or delete[]
From: Alexander Krotoff
Date: Sun, 21 Apr 1996 15:33
Date: Sun, 21 Apr 1996 15:33
33 lines
1926 bytes
1926 bytes
In article <199604181455.QAA12877@bredex.bredex.de> you wrote: > In a tutorial a student asked a very good question i think: > How can auto_ptr imagine which delete to use. > Consider: > int* p = new int; > and > int* p = new int[10]; > should result in different delete operations. > But if I let auto_ptr do the job, how does it know > which one to use? Reading WP I was confused too. Really, we need auto_ptr for array of objects more often, than auto_ptr for single object. In the last case we are able to use simple auto object instead of dynamic allocation and closely link allocated object with the automatic object (of auto_ptr type). Yes, I know there are several applications of auto_ptr which cannot be solved just by auto objects... Probably somebody from ANSI committee library WG may clean the situation. -- Alexander N. Krotoff krotoff@such.srcc.msu.su Research Computer Center tel: +7(095)939-2638 Moscow State University fax: +7(095)939-4430 [ 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:
<199604211345.RAA02244@boy.nmd.msu.ru>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: Alexander Krotoff <krotoff@boy.nmd.msu.ru> Newsgroups: comp.std.c++ Subject: Re: auto_ptr problem?: delete or delete[] Date: 21 Apr 1996 15:33:47 GMT Organization: Research Computer Center, Moscow State University Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <199604211345.RAA02244@boy.nmd.msu.ru> Reply-To: krotoff@such.srcc.msu.su NNTP-Posting-Host: taumet.eng.sun.com X-Newsreader: TIN [version 1.2 PL2] Content-Length: 967 Originator: clamage@taumet