错误运算符new []:函数不带1个参数 [英] Error operator new[] : function does not take 1 arguments
本文介绍了错误运算符new []:函数不带1个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有重载运算符new
的代码.下面的代码在Linux(gcc4x)下运行良好,但在Windows(Visual C ++ 2008 Express Edition)下运行不正常
I have code that overloads operator new
. The code below works fine under Linux (gcc4x) but not Windows (Visual C++ 2008 Express Edition)
Visual Studio 2008 Express Edition报告中的代码
The code under Visual Studio 2008 Express Edition reports
错误C2660:运算符new []:函数没有1个参数
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>
.
这篇关于错误运算符new []:函数不带1个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文