I need to write a program that reads in either from ifstream or cin, depending on parameters passed into the program at runtime.
I was planning on doing the following:
istream in;
if(argv[1] == "cin")
{
in = cin;
}
else
{
ifStream inFile;
inFile.open(argv[1].c_str());
in = inFile;
}
However, istream in protected, and I can't declare istream in. Is there a way to declare such a generic in stream?