Reputation: 7923
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();
Upvotes: 17
Views: 6769
Reputation: 254471
Most likely, you didn't include <new>
. You need that for the declarations of the standard forms of placement-new.
Upvotes: 37