定义类的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  阅读(257)  评论(0)    收藏  举报