home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mcsun!sunic!dkuug!daimi!sabroe
- From: sabroe@daimi.aau.dk (Morten Sabroe Mortensen)
- Subject: Operator "new" - how to catch array-allocation?
- Message-ID: <1992Dec14.143339.26314@daimi.aau.dk>
- Sender: news@daimi.aau.dk
- Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
- Date: Mon, 14 Dec 92 14:33:39 GMT
- Lines: 39
-
-
- As you know, it's possible to attach a special 'new' operator on a
- specific class, -something like
-
- ...
-
- class A
- {
- ...
-
- public:
- void* operator new(size_t s);
- }
-
- ...
-
- So, well, -when doing something like
-
- A* a=new A;
-
- the new 'new' for my class A is used, but when doing something like
-
- A* a=new A[25];
-
- the global new operator is used, it seems! Can it be true, it should
- 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?
- Please tell me about it! No way to catch array-allocation for a class?
- Same question goes for 'delete'. Comments and explanations greatly
- appreciated!
-
-
- -- Morten.
-
- ---------------------------------------------------------------------------
- Morten Sabroe Mortensen, e-mail: sabroe@daimi.aau.dk
- Department of Computer-science - University of Aarhus, Denmark.
- ---------------------------------------------------------------------------
-
-