c++ - 错误运算符 new[] : function does not take 1 arguments

标签 c++ visual-c++-2008 new-operator

我有重载运算符 new 的代码。下面的代码在 Linux (gcc4x) 但在 Windows (Visual C++ 2008 Express Edition) 下运行良好

Visual Studio 2008 Express Edition报表下的代码

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

最佳答案

您可能需要 #include <new> .

关于c++ - 错误运算符 new[] : function does not take 1 arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3683740/

相关文章:

c++ - 通常不内联的成员函数之前有多大?

c++ - 运算符[] C++ 获取/设置

c++ - 不允许返回类型

c++ - 如何生成vcproj文件?

c++ - 在 Visual C++ 中,出现警告但程序没有继续运行,有什么办法可以忽略它吗?

c - 为什么即使我设置了/MT 选项我也会看到 MSVCR90 依赖项?

c++ - 放置新运算符是否会禁用默认的新运算符?

c++ - OpenSSL的DTLSv1_Listen()在运行时暂停程序

c++ - 在 C++ 中动态改变指针的大小

c++ - 从工厂返回静态或动态分配的对象?