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();
1 Answer. Best explanation: The functions fillcolor(), goto() and setheading() accept arguments, whereas the function position() does not accept any arguments.
Yes, it matters. The arguments must be given in the order the function expects them.
Most likely, you didn't include <new>
. You need that for the declarations of the standard forms of placement-new.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With