I want to have a variable of type istream
which can hold either the contents of a file or a string. The idea is that if no file was specified, the variable of type istream
would be assigned with a string.
std::ifstream file(this->_path)
and
std::istringstream iss(stringSomething);
to
std::istream is
I've tried just assigning them to the istream
variable like I would with other objects that inherit from the same base class, but that didn't work.
How to assign istringstream
and ifstream
to an istream
variable?