views:

153

answers:

1

Hi, 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

Thank you very much!


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;
}


+8  A: 

You might need to #include <new>.

doron
Unfortunately I don't have VC++ to test this.
doron
Yes, that is absolutely the correct answer. Just tested it on VS2010.
DeadMG
Thank you very much !!!