#includeusing namespace std; class Point{ public: Point(int _x = 0, int _y = 0, int _z = 0):x(_x), y(_y), z(_z){} Point(){} ~Point(){} friend ostream& operator<<(ostream &os, const Point &pd); private: int x; int y; int z; }; ostream& operator<<(ostream &os, const Point &pd){ os << pd.x<<" "< 主要的注意点就是,要把函数作为class Point的友元函数,在类的外面进行定义,此外要注意return os,达到链式的作用。