C++ 报错 error C2593: 'operator <<' is ambiguous 10
#include<iostream>#include"string"usingnamespacestd;classPerson{friendostream&operato...
#include<iostream>
#include"string"
using namespace std;
class Person
{
friend ostream &operator<<( ostream &, const Person &);
friend istream &operator>>( istream &, Person &);
public:
int age;
string name;
string hobbies;
};
ostream &operator<<(ostream &output, const Person &Person )
{
output <<"("<< Person.age << ")"
<< Person.name
<< Person.name;
return output;
}
istream &operator>>(istream &input, Person &Person )
{
input>>Person.age
>>Person.name
>>Person.name;
return input;
}
void main()
{
Person lw;
cout<<"请输入李文属性"<<endl;
cin>>lw;
cout<<lw;
}
系统报错
error C2593: 'operator >>' is ambiguous
error C2593: 'operator <<' is ambiguous
求告诉错在哪里 并如何改正 展开
#include"string"
using namespace std;
class Person
{
friend ostream &operator<<( ostream &, const Person &);
friend istream &operator>>( istream &, Person &);
public:
int age;
string name;
string hobbies;
};
ostream &operator<<(ostream &output, const Person &Person )
{
output <<"("<< Person.age << ")"
<< Person.name
<< Person.name;
return output;
}
istream &operator>>(istream &input, Person &Person )
{
input>>Person.age
>>Person.name
>>Person.name;
return input;
}
void main()
{
Person lw;
cout<<"请输入李文属性"<<endl;
cin>>lw;
cout<<lw;
}
系统报错
error C2593: 'operator >>' is ambiguous
error C2593: 'operator <<' is ambiguous
求告诉错在哪里 并如何改正 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询