问题
I have code that overloads operator new
. The code below works fine under Linux (gcc4x) but not Windows (Visual C++ 2008 Express Edition)
The code under Visual Studio 2008 Express Edition reports
error C2660: operator new[] : function does not take 1 arguments
class dummy{};
void* operator new[] (size_t size, dummy gcp)
{
return ::operator new[](size); //error
}
int main()
{
dummy dummyobj;
dummy* ptr = new (dummyobj) dummy[5];
return 0;
}
回答1:
You might need to #include <new>
.
来源:https://stackoverflow.com/questions/3683740/error-operator-new-function-does-not-take-1-arguments