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