home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!microsoft!hexnut!jimad
- From: jimad@microsoft.com (Jim Adcock)
- Subject: Re: Operator "new" - how to catch array-allocation?
- Message-ID: <1992Dec15.192946.25542@microsoft.com>
- Date: 15 Dec 92 19:29:46 GMT
- Organization: Microsoft Corporation
- References: <1992Dec14.143339.26314@daimi.aau.dk>
- Lines: 26
-
- In article <1992Dec14.143339.26314@daimi.aau.dk> sabroe@daimi.aau.dk (Morten Sabroe Mortensen) writes:
- |A* a=new A[25];
- |
- |the global new operator is used, it seems! Can it be true, it should
- |work like this?
-
- It should work like this? It does work like this.
-
- |Until I tried, I thought, A's 'new' would just get a bigger
- |argument - but maybe there is a very good reason, it works like this?
-
- Maybe. The argument being that class operator new should be allowed to
- handled fixed-size allocations.
-
- |Please tell me about it! No way to catch array-allocation for a class?
-
- Way. Catch array-allocation for a class by preventing array allocations.
- For example make constructors private. Or no default constructors.
-
- |Same question goes for 'delete'. Comments and explanations greatly
- |appreciated!
-
- If you want to perform custom new and delete on arrays of objects make
- that array a class. If you want the capabilities of classes, then
- make it a class. The built-in array capabilities of C++ are a left-over
- from C days, and are not to be taken seriously.
-