home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!rock!concert!duke!mcduff.uncg.edu!brinerj
- From: brinerj@mcduff.uncg.edu (Jack V. Briner Jr.)
- Newsgroups: gnu.g++.help
- Subject: new operator with multiple arguments (gcc-2.2.2)
- Message-ID: <22983@duke.cs.duke.edu>
- Date: 22 Jan 93 21:24:50 GMT
- Sender: news@duke.cs.duke.edu
- Reply-To: brinerj@mcduff.uncg.edu (Jack V. Briner Jr.)
- Organization: UNCG Department of Mathematics
- Lines: 44
- Nntp-Posting-Host: mcduff.uncg.edu
-
- I would like to pass arguments to the new operator (to select memory from
- different segments). g++ does not seem to have this implemented under gcc-2.2.2. Here is some example code that compiles fine under cfront. Does a
- newer release accept this code?
-
- Thanks,
- Jack
-
-
- #include <iostream.h>
- #include <stddef.h>
- class t {
- public:
- int i;
-
- // ok
- void *operator new(size_t sz) {
- t *n;
- n = (t *)new char[sz];
- return n;
- }
-
- // not ok when used in main
- void *operator new(size_t sz,int i) {
- t *n;
- n = (t *)new char[sz];
- n->i = i; // not what I am really doing in my application
- return n;
- }
-
- };
-
- main () {
-
- t *a = new t; // ok
- t *b = new(5) t; // not ok, parse error before `5'
- }
-
-
-
- --
- Jack V. Briner,Jr. Department of Mathematics
- brinerj@mcduff.uncg.edu University of North Carolina at Greensboro
- brinerj@steffi.uncg.edu Greensboro, NC 27412
- brinerj@UNCG.Bitnet (919)334-5836
-