Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'operator new' : function does not take 2 arguments

I cannot seem to get my placement new to work for some reason. Based on this question, I have set this up correctly.

However, I continue to get the error:

'operator new' : function does not take 2 arguments

Here is my code:

char * p = new char [sizeof(Node) * 5];
Node* node = new(p) Node();

where Node is a linked list node. I have tried to simplify this down based on the other stack overflow question, and I am still getting the same error:

char *buf  = new char[sizeof(int)]; // pre-allocated buffer
int *p = new (buf) int;

Does anyone know why I am having this issue?

Any help is greatly appreciated!

PS, this works:

Node* node = new Node();
like image 536
Serguei Fedorov Avatar asked Nov 07 '13 08:11

Serguei Fedorov


People also ask

What function does not take any arguments?

1 Answer. Best explanation: The functions fillcolor(), goto() and setheading() accept arguments, whereas the function position() does not accept any arguments.

Does the order of the arguments in a call to a function make a difference?

Yes, it matters. The arguments must be given in the order the function expects them.


1 Answers

Most likely, you didn't include <new>. You need that for the declarations of the standard forms of placement-new.

like image 53
Mike Seymour Avatar answered Oct 30 '22 22:10

Mike Seymour