Newsgroups: comp.os.msdos.djgpp From: manni DOT heumann AT gmx DOT de (Manni Heumann) Subject: Re: delete OR delete[] ? References: <8ngta8$27b$2 AT info DOT cyf-kr DOT edu DOT pl> X-Newsreader: News Xpress 2.01 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Thu, 17 Aug 2000 15:32:39 GMT NNTP-Posting-Host: dhcp33-228.uni-bielefeld.de Message-ID: <399c05a2$1_1@news.uni-bielefeld.de> X-Trace: 17 Aug 2000 17:32:50 +0200, dhcp33-228.uni-bielefeld.de Lines: 25 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Rafał Maj" wrote: >What is difference between delete and delete[] ? >With one should I use to delete array : char *ptr = new char[1024] ? >When I'm overloading operator delete for some class, should I overload >operator delete[] too ? > > > If you are using new to create an Array, you have to use delete[]. That means, when you use new with [] (like in your example), you have to use delete []. Overloading operator delete is rarely necessary. Only with very special classes that get a special memory region from their own operator new, is it necessary to provide an overloaded form of delete. I wouldn't worry about that. No offense, but someone, who is just learning how to use delete, should not try to overload delete. -- Manni "Life would be much easier if I had the source code."