使用make_pair报错当使用,并将其参数用作字符串时,编译就会报错.例如:mapcoll;coll.insert(make_pair("zxr","xh"))当然我在程序顶端包含了string,map,也写了using namespace std;错误提示如下:f:\microsoft visual s

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/08 21:35:47
使用make_pair报错当使用,并将其参数用作字符串时,编译就会报错.例如:mapcoll;coll.insert(make_pair(

使用make_pair报错当使用,并将其参数用作字符串时,编译就会报错.例如:mapcoll;coll.insert(make_pair("zxr","xh"))当然我在程序顶端包含了string,map,也写了using namespace std;错误提示如下:f:\microsoft visual s
使用make_pair报错
当使用,并将其参数用作字符串时,编译就会报错.例如:
mapcoll;
coll.insert(make_pair("zxr","xh"))
当然我在程序顶端包含了string,map,也写了using namespace std;
错误提示如下:f:\microsoft visual studio\vc98\include\utility(21) :error C2536:'std::pair::first' :cannot specify explicit initializer for arrays
f:\microsoft visual studio\vc98\include\utility(25) :see declaration of 'first'
f:\microsoft visual studio\vc98\include\utility(21) :while compiling class-template member function '__thiscall std::pair::std::pair(const char (&)[4],const char (&)[3])'
f:\microsoft visual studio\vc98\include\utility(21) :error C2536:'std::pair::second' :cannot specify explicit initializer for arrays
f:\microsoft visual studio\vc98\include\utility(26) :see declaration of 'second'
f:\microsoft visual studio\vc98\include\utility(21) :while compiling class-template member function '__thiscall std::pair::std::pair(const char (&)[4],const char (&)[3])'
错误指示:
#ifdef _MSC_VER
#pragma pack(push,8)
#endif /* _MSC_VER */
_STD_BEGIN
// TEMPLATE STRUCT pair
template struct pair {
typedef _T1 first_type;
typedef _T2 second_type;
pair()
:first(_T1()),second(_T2()) {}
pair(const _T1& _V1,const _T2& _V2)
:first(_V1),second(_V2) {}
template pair(const pair &p)
:first(p.first),second(p.second) {}
_T1 first;
_T2 second;
};

使用make_pair报错当使用,并将其参数用作字符串时,编译就会报错.例如:mapcoll;coll.insert(make_pair("zxr","xh"))当然我在程序顶端包含了string,map,也写了using namespace std;错误提示如下:f:\microsoft visual s
改成:coll.insert(make_pair(string("zxr"),string("xh")))