这个C++问题有点难倒我了,自己菜啊,请教高人

来源:百度知道 编辑:UC知道 时间:2024/05/16 09:01:10
cout<<"请输入姓名"<<endl;//输入名字
cin>>owner_name[pro_num];

很正常的两句啊,偏偏是错的,错误如下
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)

看提示是说>>不能输出指定的类型;
莫非你的owner_name是一个结构数组而你又没有对>>进行运算符重载?

命名空间的问题吧

晕。数组不能整体赋值,知道吗?当然这里也不能这样用,按你的意思要把输入赋值给数组整体。 编译器的提示很明白了。
for(int i=0;i<pro_num;){

cin>>owner_name[i];
}

看看下面行不行
cout<<"请输入姓名"<<endl;//输入名字
cin>>owner_name