home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!ukma!usenet.ins.cwru.edu!agate!iat.holonet.net!rkinder
- From: rkinder@iat.holonet.net (Robert J. Kinder)
- Subject: Re: Using delete with arrays - help please!
- Message-ID: <BxuI1G.3Mo@iat.holonet.net>
- Organization: HoloNet (BBS: 510-704-1058)
- References: <1992Nov16.023852.24205@gopher.dosli.govt.nz>
- Date: Tue, 17 Nov 1992 05:32:02 GMT
- Lines: 42
-
- Borland C++ 3.1 has two implementations of operator new() and delete().
- These may be found in the files vnew.cpp, vdel.cpp, new.cpp, and del.cpp.
-
- The vnew.cpp & vdel.cpp are for 'vector' (a.k.a. arrays) new and delete.
-
- The Borland C++ runtime library routine _vector_new() is called to
- allocate arrays of objects having constructors. _vector_delete() is
- called to deallocate arrays of objects having destructors. These two
- routines eventually call _new() and _delete() to do the actual memory
- allocations.
-
- The statements
-
- char str[80] = new char[80];
- delete [] str;
-
- allocate and free an array of chars. There are no constructor or
- destructor methods to be called.
-
- The statements
-
- myClass stuff[5] = new myClass[5];
- delete [] stuff;
-
- are handled via the vector new and delete functions. The myClass objects
- presumably have constructors and destructors that need to be called.
-
- You're getting a NULL pointer assigment error if you try
-
- delete stuff;
-
- (the array [] brackets are omitted) probably because vector new & delete
- saves the number of objects in the array by modifying the memory pointer
- value returned by the basic new() and delete().
-
-
-
- --
- // rkinder@holonet.net International Software Solutions, Inc. -
- // Robert J. Kinder, Jr. Boca Raton, Florida -
- // 1-800-788-4774 -
- // "We're having a real Ted Bundy day here." - C. Bernholtz
-