标题:生成一个pair对象在VC++6.0无法运行
只看楼主
renhao153
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-11-10
 问题点数:0 回复次数:0 
生成一个pair对象在VC++6.0无法运行
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
void main()
{
    pair<string,int> anon;
    string first,last;
    while(cin>>first>>last)
    {
      anon=make_pair(first,last);
      if (first==""||last=="")
          break;
    }
   
}
如下错误请高手回答一下
d:\vc98\include\utility(23) : error C2440: 'initializing' : cannot convert from 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'int'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
        E:\电子图书\VC制作\C测试\cs1.cpp(13) : see reference to function template instantiation '__thiscall std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::std::pair<class std::basic_string<cha
r,struct std::char_traits<char>,class std::allocator<char> >,int>(const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::al
locator<char> > > &)' being compiled
d:\vc98\include\utility(23) : error C2439: 'second' : member could not be initialized
        d:\vc98\include\utility(26) : see declaration of 'second'
        E:\电子图书\VC制作\C测试\cs1.cpp(13) : see reference to function template instantiation '__thiscall std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::std::pair<class std::basic_string<cha
r,struct std::char_traits<char>,class std::allocator<char> >,int>(const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::al
locator<char> > > &)' being compiled
搜索更多相关主题的帖子: pair 对象 运行 
2008-09-08 21:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-232190-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.117837 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved