C++ Streams.

Keith Robison robison1 at husc10.harvard.edu
Fri Jun 11 09:50:16 EST 1993

What you can do is pass around a pointer to an istream (ifstreams are
derived from istreams).  You can, of course, do the same with ostreams.

// example  (warning! I haven't actually compiled this, but it should 
//           at least illustrate the idea)
#include <iostream.h>

// note: you should really encapsulate this as a class, with this
// as the ctor.  Otherwise you might leave files open
// or use an un
void open  (const char* fileName)
  if (*fileName='-') osPt = &cin;       // filename - is stdin
  else osPt = new ostream (fileName);

Keith Robison
Harvard University
Department of Cellular and Developmental Biology
Department of Genetics / HHMI

robison at biosun.harvard.edu 

More information about the Bio-soft mailing list

Send comments to us at biosci-help [At] net.bio.net