| | |
problem with headers and streams
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I ve read that iostream is a derived class of fstream ,so including the "fstream" header is all sufficient to perform console i/p and o/p(ie cin and cout) .this worked fine as long as I used Turbo C++ compiler but now I ve switched to Bloodshed Dev C++ compiler and it gives an error that cin is not recognized....it works fine only if I include both "iostream" and "fstream" in my program ....please help
Last edited by sugantha; Sep 18th, 2006 at 8:22 pm.
Some C++ compilers do not require IO imports to include cin/cout. The same is true with some C compilers and printf etc.
•
•
Join Date: Aug 2005
Posts: 148
Reputation:
Solved Threads: 6
Well, according to this:
http://www.cppreference.com/cppio/index.html
cin, cout are defined in iostream.
And this will also help ypu understand what is going on.
http://www.cplusplus.com/ref/iostream/
I hope it helps!
http://www.cppreference.com/cppio/index.html
cin, cout are defined in iostream.
And this will also help ypu understand what is going on.
http://www.cplusplus.com/ref/iostream/
I hope it helps!
OK, so use that then from now on and don't assume that a particular implementation choice about the inheritance of various objects will be true in other implementations.
My guess is you "got away with" using fstream for cout previously, but this "trick" no longer works on your new compiler.
Which is why you should learn from high quality sources of documentation (like the C++ standard), rather than relying on your reverse engineered observations of a particularly old compiler.
Using multiple compilers even when you don't have to is also a good way of flushing out any assumptions you might be making.
I'm presently using 3 different compilers with pretty strict error checking. It's been a long while since I last used just one compiler for a whole project.
My guess is you "got away with" using fstream for cout previously, but this "trick" no longer works on your new compiler.
Which is why you should learn from high quality sources of documentation (like the C++ standard), rather than relying on your reverse engineered observations of a particularly old compiler.
Using multiple compilers even when you don't have to is also a good way of flushing out any assumptions you might be making.
I'm presently using 3 different compilers with pretty strict error checking. It's been a long while since I last used just one compiler for a whole project.
![]() |
Similar Threads
- need code for NFA to DFA (Computer Science)
- Unix, C++, pipe and fork (C++)
- Fixed table headers problem .. (HTML and CSS)
- Converting without additional headers (C)
- C++ linking problem (C++)
- include(); problem (PHP)
- form to mail - Hebrew problem (PHP)
- Mode 13 graphics,Problem with io streams and new operator (C++)
- modem drivers error installing and another problem (*nix Hardware Configuration)
Other Threads in the C++ Forum
- Previous Thread: c++ white space question?
- Next Thread: new to C++ calculator problem
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph gui homeworkhelp iamthwee ifstream image input int java lib library list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






