Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!mintaka!daemon From: andru@proton.lcs.mit.edu (Andrew Myers) Newsgroups: comp.lang.c++ Subject: overloading new() in g++ Message-ID: <1990Oct2.215020.23361@mintaka.lcs.mit.edu> Date: 2 Oct 90 21:50:20 GMT Sender: daemon@mintaka.lcs.mit.edu (Lucifer Maleficius) Organization: MIT Laboratory for Computer Science Lines: 22 The gnu C++ compiler doesn't like the following program, yet so far as I recall, it works fine on C++2.0 from AT&T. Anyone know what's going wrong? It reports "parse error just before malloc" on the line with the second call to new. Seemingly, g++ doesn't support additional arguments to new. -- Andrew #include "new.h" extern "C" void *malloc(size_t); class A { public: void *operator new(size_t s) { return malloc(s); } void *operator new(size_t s, void *x) { return x; } int b; }; main() { A* a = new A; A* a2 = new(malloc(sizeof(A))) A; }