DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
iostream examples

Assignment

In the old library it was possible to assign one stream to another. This is possible in the iostream library only if the left hand side is declared to be an assignable class. A general assignment cannot be allowed because of the interactions of derived classes. What, for example, should be the effect of assigning an ifstream to an istrstream? Most programs that use this feature can be converted by using a reference or pointer to a stream. The old usage:

   ostream out ;
   out = cout ;
   out << x ;
can be replaced by:
   ostream* out ;
   out = cout ;
   out << x ;
or:
   ostream_with_assign out ;
   out = &cout ;
   *out << x ;


Next topic: char insertion operator
Previous topic: Interactions with stdio

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004