You should declare the operator

ostream& operator<<(ostream&,CObject const&);

and implement this operator to append the required format to the given
ostream object. You may need to declare this operator as a friend of
CObject class if you use protected or private members of CObject.

Fenglou Mao wrote:

> Dear all,
>      I have a class, for example, CObject, I want statement
> like this:
>
>      CObject O1;
> //...O1's value is set.
>      cout<<O1<<"\n";
>
>      can output the value of O1 using format I wanted.
>      How can I do that?
>
> Sincerely Yours,
>
> FengLou Mao
> *******************************
> ADD:Mr. FengLou Mao
>     Peking University
>     BeiJing
>     P.R.China
> Tel:86-10-62751490
> Fax:86-10-62751725


Reply via email to