Try:
std::ifstream* myStream; std::istream* myOtherStream = static_cast<std::istream*>(myStream); myOtherStream = myStream;
The same thing works if you have a link (&) to the stream type. static_cast is preferred in this case, since the cast is performed at compile time, allowing the compiler to report an error if translation is not possible (i.e. istream not a basic ifstream type).
In addition, and you probably already know this, you can pass an ifstream pointer / link to any function that accepts an istream pointer / link. For example, a language is resolved as follows:
void processStream(const std::istream& stream); std::ifstream* myStream; processStream(*myStream);
Steve guidi
source share