error C2593: 'operator <<' is ambiguous 执行 cl.exe 时出错.
#include<iostream>usingnamespacestd;classA{public:A(inta,intb):x(a),y(b){}friendostre...
#include<iostream>
using namespace std;
class A
{
public:
A(int a,int b):x(a),y(b){}
friend ostream &operator << (ostream&, const A&);
int x;
int y;
};
ostream &operator << (ostream &output, const A &p)
{
output<<"("<<p.x<<","<<p.y<<")"<<endl;
return output;
}
int main()
{
A a(1,2);
cout<<a;
return 0;
} 展开
using namespace std;
class A
{
public:
A(int a,int b):x(a),y(b){}
friend ostream &operator << (ostream&, const A&);
int x;
int y;
};
ostream &operator << (ostream &output, const A &p)
{
output<<"("<<p.x<<","<<p.y<<")"<<endl;
return output;
}
int main()
{
A a(1,2);
cout<<a;
return 0;
} 展开
展开全部
#include<iostream.h>
class A
{
public:
A(int a,int b):x(a),y(b){}
friend ostream &operator << (ostream&, const A&);
int x;
int y;
};
ostream &operator << (ostream &output, const A &p)
{
output<<"("<<p.x<<","<<p.y<<")"<<endl;
return output;
}
int main()
{
A a(1,2);
cout<<a;
return 0;
}
友元函数是不能用using namespace std;
得用<iostream.h>
class A
{
public:
A(int a,int b):x(a),y(b){}
friend ostream &operator << (ostream&, const A&);
int x;
int y;
};
ostream &operator << (ostream &output, const A &p)
{
output<<"("<<p.x<<","<<p.y<<")"<<endl;
return output;
}
int main()
{
A a(1,2);
cout<<a;
return 0;
}
友元函数是不能用using namespace std;
得用<iostream.h>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询