I am using two compilers g++ and Dev – C++. when I compile my program on Dev-C++ it compiles perfectly. but when i try to compile it on g++ it gives me two errors:
In file included from a2test.cpp:27: ----.h:25: error: 'ostream' has not been declared ----.h:26: error: 'istream' has not been declared
Can anyone tell me what can I do to solve this problem.
Thanks
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
While Dev-C++ may have
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.