home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.g++.help
- Path: sparky!uunet!usc!sol.ctr.columbia.edu!caen!nic.umass.edu!cis.umassd.edu!ulowell!cs.ulowell.edu!jrichard
- From: jrichard@cs.ulowell.edu (John 'MacGyver' Richardson)
- Subject: help with operator new (can you overload it?)
- Message-ID: <1992Aug23.181826.28513@ulowell.ulowell.edu>
- Sender: usenet@ulowell.ulowell.edu (News manager - ulowell)
- Organization: University of Massachusetts at Lowell Computer Science
- Date: Sun, 23 Aug 1992 18:18:26 GMT
- Lines: 32
-
-
- I'm having some trouble trying to overload the new operator with g++2.2.2.
- Is there some switch to turn on overloading for the new operator?
-
- The following example program doesn't complile under g++ but does under
- cfront3.0. Can someone tell me what's up here? Email if possible.
- Thanks.
-
- -------------------
- #include <stdio.h>
- #include <string.h>
-
- inline void *operator new(size_t, void *addr) {
- return addr;
- }
-
- int main() {
- char buffer[1000];
- strcpy(buffer, "Hello Gnu World\n"); // I realize this is weird
- // but its just an example.
- char *s = new (buffer) char; // g++ gives error here.
- printf("buffer is %s", buffer);
- }
-
-
- John 'MacGyver' Richardson |"sun dogs fire on the horizon \ \ \
- jrichard@cs.ulowell.edu | meteor rain stars across the night * * \ /\
- jrichard@duck.ulowell.edu | ...the spark still flies /\ * / \
- | reflected in another pair of eyes." /\ / \/\/
- ------ \ / /
-
-
-