zoukankan      html  css  js  c++  java
  • include vector 编译出错VC++

    error C2665: “operator new” : 5个重载中没有一个可以转换参数1(从“const char [71]”类型)
    这个错误是怎么回事啊,搜索了整个项目好像没有可疑的new操作阿。这个错误是在将两个工程合并成一个过程中产生的。合并前没有这样的错误。
    MainFrm.cpp
    d:Program FilesMicrosoft Visual Studio .NET 2003Vc7includexmemory(34) : error C2665: “operator new” : 5 个重载中没有一个可以转换参数 1(从“const char [71]”类型)
            d:Program FilesMicrosoft Visual Studio .NET 2003Vc7include ew.h(100): 可能是“void *operator new(size_t,const std::nothrow_t &) throw()”
            d:Program FilesMicrosoft Visual Studio .NET 2003Vc7include ew.h(108): 或       “void *operator new(size_t,void *)”
            试图匹配参数列表“(const char [71], int)”时
            d:Program FilesMicrosoft Visual Studio .NET 2003Vc7includexmemory(137) : 参见对正在编译的函数模板实例化“_Ty *std::_Allocate<std::allocator<_Ty>::value_type>(size_t,_Ty *)”的引用
            with
            [
                _Ty=std::allocator<char>::value_type
            ]
            d:Program FilesMicrosoft Visual Studio .NET 2003Vc7includexmemory(136) : 编译类模板成员函数“std::allocator<_Ty>::pointer std::allocator<_Ty>::allocate(std::allocator<_Ty>::size_type)”时
            with
            [
                _Ty=char
            ]
            d:Program FilesMicrosoft Visual Studio .NET 2003Vc7includexstring(30) : 参见对正在编译的类模板实例化“std::allocator<_Ty>”的引用
            with
            [
                _Ty=char
            ]
            d:Program FilesMicrosoft Visual Studio .NET 2003Vc7includexstring(46) : 参见对正在编译的类模板实例化“std::_String_val<_Ty,_Alloc>”的引用
            with
            [
                _Ty=char,
                _Alloc=std::allocator<char>
            ]
            d:Program FilesMicrosoft Visual Studio .NET 2003Vc7includexstring(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的后面。

    // http://blog.csdn.net/machh/article/details/43450725

  • 相关阅读:
    SQL SERVER 查询性能优化——分析事务与锁(一)
    SQL Server 查询性能优化——索引与SARG(三)
    SQL Server 查询性能优化——索引与SARG(二)
    SQL SERVER的锁机制(四)——概述(各种事务隔离级别发生的影响)
    SQL SERVER的锁机制(一)——概述(锁的种类与范围)
    SQL SERVER的锁机制(三)——概述(锁与事务隔离级别)
    关于AutoResetEvent的使用
    ASP.NET缓存
    Spring Framework 3.2.1 发布
    ExactImage 0.8.8 发布,C++ 图像处理库
  • 原文地址:https://www.cnblogs.com/liflying/p/4280119.html
Copyright © 2011-2022 走看看