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

Some C++ compilers do not require IO imports to include cin/cout. The same is true with some C compilers and printf etc.

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.

This article has been dead for over six months. Start a new discussion instead.