🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Jack V. Briner Jr. Fri, 22 Jan 1993 21:24
new operator with multiple arguments (gcc-2.2.2)
#695
Author: Jack V. Briner Jr.
Date: Fri, 22 Jan 1993 21:24
44 lines
1538 bytes
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
Re: new operator with multiple arguments (gcc-2.2.2)
#697
Author: Joe Buck
Date: Sat, 23 Jan 1993 00:55
11 lines
843 bytes
In article <22983@duke.cs.duke.edu> brinerj@mcduff.uncg.edu (Jack V. Briner Jr.) writes:
>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.

Actually, it did, but used a different syntax.

The current version, gcc-2.3.3, supports the ARM (official) syntax and
compiles your program correctly.
--
Joe Buck	jbuck@ohm.berkeley.edu
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