BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #32487同步于 2009/12/1
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

求达人指点:一个小程序,vc6.0的编译器老报错?

hjxhjh
2009/12/1镜像同步8 回复
就这么一个小小的程序,为什么会出现>>符号没有定义的情况呢? 如下: error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion) 程序如下,在dev c++ 平台上面没有报错!! #include <iostream> #include <vector> #include <map> #include <iterator> using namespace std; void main() { map<string ,vector<string> > fnmap; string fname; string lname; do { cout<<"please enter the family name"<<endl <<"enter Ctrl+Z to exit!"<<endl; cin>>fname; if (!cin) { break; } vector<string> vlname; pair< map<string ,vector<string> >::iterator,bool > pit=fnmap.insert(make_pair(fname,lname)); if (!pit.second) { cout<<"the family name is already there"<<endl; continue; } cout<<"please enter the children's name Ctrl+Z to exit"<<endl; while (cin) { cin>>lname; vlname.push_back(lname); } cin.clear(); fflush(stdin); } while (cin); }
订阅后,新回复会通过你的通知中心匿名送达。
8 条回复
vcpp机器人#1 · 2009/12/1
fnmap.insert(make_pair(fname,lname)); //这一句有问题,看你声明的fnmap的格式 //map<string ,vector<string> > fnmap; 【 在 hjxhjh 的大作中提到: 】 : 就这么一个小小的程序,为什么会出现>>符号没有定义的情况呢? : 如下: : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion) : ...................
hjxhjh机器人#2 · 2009/12/1
不好意思,这两个变量太相像了~~~ fname是String类型的,然后lname是vector<string>类型的 fnmap是map<string ,vector<string> >类型的 感觉类型没有错误呀? 【 在 vcpp 的大作中提到: 】 : fnmap.insert(make_pair(fname,lname)); //这一句有问题,看你声明的fnmap的格式 : //map<string ,vector<string> > fnmap;
vcpp机器人#3 · 2009/12/1
string fname; string lname; //?!你的代码里不是这么写的么? string 与 fnmap的第二个参数vector<string>类型不匹配! 【 在 hjxhjh 的大作中提到: 】 : 不好意思,这两个变量太相像了~~~ : fname是String类型的,然后lname是vector<string>类型的 : fnmap是map<string ,vector<string> >类型的 : ...................
hjxhjh机器人#4 · 2009/12/1
哦 ,我看错了~~不好意思,谢谢你哈~~。 对 对~~ 是要把make_pair(fname,lname) 改成make_pair(fname,vlname) 可是时还是报错,还是以前的那个错误? 【 在 vcpp 的大作中提到: 】 : string fname; : string lname; : //?!你的代码里不是这么写的么?
epavel机器人#5 · 2009/12/1
#include <string> -_-||
hjxhjh机器人#6 · 2009/12/1
谢谢~~~ 没有养成一个好习惯~~哎 对自己无语-_-' 【 在 epavel 的大作中提到: 】 : #include <string> : -_-||
epavel机器人#7 · 2009/12/1
【 在 hjxhjh 的大作中提到: 】 : 谢谢~~~ : 没有养成一个好习惯~~哎 : 对自己无语-_-' 这个慢慢就好了,我一开始也这样,呵呵
macrox机器人#8 · 2009/12/2
Good