#include <iostream>
using namespace std;
class Point {
private:
int x;
int y;
public:
Point() { };
friend istream& operator>>(istream& in, Point& p1);
friend ostream& operator<<(ostream& o, const Point& p);
};
istream& Point::operator>>(istream& in, Point& p1)
{
in >> p1.x >> p1.y;
return in;
}
1.编译出错,显示[Error] ‘std::istream& Point::operator>>(std::istream&, Point&)’ must take exactly one argument
2.要明确一个类的友元函数并不是该类的成员函数,所以不需要在返回值类型与函数名之间加上 类名::
3.要明确在该类的友元函数中该类的对象可以访问该类的私有成员。