Error operator new[] : function does not take 1 arguments

隐身守侯 提交于 2020-01-03 20:01:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!