定义类的ostream输出
class Tree { int height; public: Tree(int treeHeight):height(treeHeight){} ~Tree(){ cout<<"*"; } friend ostream& operator<<(ostream& os, const Tree* t){ return os<<"Tree height is: "<<t->height<<endl; } };
class Tree { int height; public: Tree(int treeHeight):height(treeHeight){} ~Tree(){ cout<<"*"; } friend ostream& operator<<(ostream& os, const Tree* t){ return os<<"Tree height is: "<<t->height<<endl; } };