gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 19:50:11 49 4
gpt4 key购买 nike

我有重载运算符 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/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com