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.
I think you did'nt read my question clearly...I asked if iostream is a derived class of fstream then it has to inherit all its properties...so cin and cout SHOULD work fine....it does so with the Borland compiler but not with Dec-C++ compiler ...why??
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.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.