• 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

  • 相关阅读:
    SAP BW 例程(Routine)【开始例程、关键值或特性的例程、结束例程】
    sap 提取字符串中汉字
    判断当前一个物料被其他人锁定
    ABAP "FOR ALL ENTRIES IN" 使用指南
    ABAP检查日期and时间合法性的函数
    READ语句相关
    QUERY客户出口变量的I_STEP解释
    Abap 内表的语法
    Ancient Knight(打造Windows Mobile平台最专业的游戏修改器)
    VC通用控件自适应屏幕类
  • 原文地址:https://www.cnblogs.com/liflying/p/4280119.html
Copyright © 2020-2023  润新知