满载"<<" ostream不明确 VS2010
重载"<<" ostream不明确 VS2010
code :
#include<iostream>
using namespace std;
class Point
{
public:
Point(int x, int y):a(x),b(y){}
friend ostream &operator<<(std::ostream &stream,Point &Pone);
private:
int a;
int b;
}
ostream &operator <<(ostream &stream,Point &Pone)
{
stream << Pone.a << "," << Pone.b << endl;
return stream;
}
ostream 不明确 operator无法重载按返回类型区分的函数。
------解决方案--------------------
分号忘了加了
code :
#include<iostream>
using namespace std;
class Point
{
public:
Point(int x, int y):a(x),b(y){}
friend ostream &operator<<(std::ostream &stream,Point &Pone);
private:
int a;
int b;
}
ostream &operator <<(ostream &stream,Point &Pone)
{
stream << Pone.a << "," << Pone.b << endl;
return stream;
}
ostream 不明确 operator无法重载按返回类型区分的函数。
------解决方案--------------------
分号忘了加了