🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by John 'MacGyver' Richardson Sun, 23 Aug 1992 18:18
help with operator new (can you overload it?)
#145
Author: John 'MacGyver' Richardson
Date: Sun, 23 Aug 1992 18:18
30 lines
1655 bytes
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." /\ /  \/\/
                                                           ------  \   / / 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads