Is there a common interface for cin and file input?
I want to make a program that has an optional parameter
prog [input-file]
If an input file is specified, then it should read from the file, and if not, it should read from cin.
From what I can tell, they both implement istream
. How would you set up it so that I could do something like in >> var
, where in
is an istream
.