定义类的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;
    }
};

 

posted @ 2013-05-06 20:21  wiessharling  阅读(247)  评论(0编辑  收藏  举报