您的位置:首页 > 运维架构

error C2665: “operator new” : 5个重载中没有一个可以转换参数1(从“const char [71]”类型)

2015-02-03 15:45 716 查看
error C2665: “operator new” : 5个重载中没有一个可以转换参数1(从“const char [71]”类型)

这个错误是怎么回事啊,搜索了整个项目好像没有可疑的new操作阿。这个错误是在将两个工程合并成一个过程中产生的。合并前没有这样的错误。

MainFrm.cpp

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xmemory(34) : error C2665: “operator new” : 5 个重载中没有一个可以转换参数 1(从“const char [71]”类型)

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\new.h(100): 可能是“void *operator new(size_t,const std::nothrow_t &) throw()”

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\new.h(108): 或 “void *operator new(size_t,void *)”

试图匹配参数列表“(const char [71], int)”时

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xmemory(137) : 参见对正在编译的函数模板实例化“_Ty *std::_Allocate<std::allocator<_Ty>::value_type>(size_t,_Ty *)”的引用

with

[

_Ty=std::allocator<char>::value_type

]

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xmemory(136) : 编译类模板成员函数“std::allocator<_Ty>::pointer std::allocator<_Ty>::allocate(std::allocator<_Ty>::size_type)”时

with

[

_Ty=char

]

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(30) : 参见对正在编译的类模板实例化“std::allocator<_Ty>”的引用

with

[

_Ty=char

]

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(46) : 参见对正在编译的类模板实例化“std::_String_val<_Ty,_Alloc>”的引用

with

[

_Ty=char,

_Alloc=std::allocator<char>

]

d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(1569) : 参见对正在编译的类模板实例化“std::basic_string<_Elem,_Traits,_Ax>”的引用

with

[

_Elem=char,

_Traits=std::char_traits<char>,

_Ax=std::allocator<char>

]

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

据说是因为STL与DEBUG NEW运算符的冲突(影响list、vector等)

解决方法1:注释掉以下代码:

#ifdef _DEBUG

#define new DEBUG_NEW

#endif

解决方法2:

将:代码中的#include <vector>移到stdafx.h的开头,也就是#program once的后面。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐