istream and ostream problem – C++

Make sure you include fstream. Also, put “std::” before ostream or put “using namespace std” somewhere.

It would help if you posted the code, as right now I’m just guessing based on common mistakes.

I would guess you forgot to include fstream because different compilers may use different header files and it may be the case that g++ has a header file with

// iostream
#include <fstream>

While Dev-C++ may have

// iostream
// no include for fstream in this file

So you’re accidentally importing the correct header file rather than doing it explicitly.

For header files, I just use this site when I forget which one.

ostream – C++ Reference

It seems you need to include ostream to get ostream. Probably the same thing for istream.

Leave a Comment