Path: utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!mips!ardent!jra!jss From: jss@jra.ardent.com Newsgroups: comp.lang.c++ Subject: Re: ostream_with_assign versus specialization of cout? Message-ID: <9806@ardent.UUCP> Date: 21 Dec 89 20:29:38 GMT References: <1989Dec19.175438.12843@odi.com> Sender: news@ardent.UUCP Reply-To: jss@jra.ardent.com () Organization: Ardent Computer Corp., Sunnyvale, CA Lines: 34 In article <1989Dec19.175438.12843@odi.com> benson@odi.com () writes: >I've got a derived class of ostream that internally sets the unitbuf >flag. I tried > > cout = one_of_my_streams; > >The operator= goes and reinitializes the stream, clearing the >crucial flag (unitbuf). If operator= is going to do this, >it seems that cout should have been a pointer. As it is, >one can't make cout be another type, it seems. I tend to agree. The predefined classes ought to have been pointers rather than streams, however I didn't feel that iostreams could make that radical a departure from streams. I originally tried having pointers and #defining the predefined #define cout (*cout_ptr) but it eventually became clear to me that macros here were a bad idea. (If nothing else they create confusing error messages for beginners.) My own coding style uses a global ostream* and assigns &cout to the global when appropriate rather than assigning streams to cout. For a long time I resisted having assignment of streams at all in iostream. I finally allowed it primarily for backward compatibility. (Although it was a nightmare to implement) But it was never clear to me what the semantics of the assignment should be. Jerry Schwarz jss@ardent.com