tags:

views:

212

answers:

2

What is the difference between iostream and iostream.h?

+15  A: 

iostream.h is deprecated by those compilers that provide it, iostream is part of the C++ standard.

To clarify explicitly there is no mention of iostream.h at all in the current C++ standard (INCITS ISO IEC 14882 2003).

Edit: As @Jerry mentioned, not only does the current standard not mention it, but no standard for C++ mentions it.

Brian R. Bondy
You should probably mention the std namespace.
zdan
@Jerry: Kept the wording but clarified the meaning
Brian R. Bondy
@Jerry: Thanks, added.
Brian R. Bondy
+1  A: 

iostream is a standard header. iostream.h is a non-standard header that was very common in pre-standard C++, and is what iostream evolved from. It's still common to have iostream.h around, presumably for use with older programs.

If your implementation have a working copy of iostream.h, it is probably the same as iostream except that everything in iostream is in the std namespace, while iostream.h generally preceded namespaces, and didn't use them.

If your implementation has both iostream and iostream.h, iostream is likely to work like:

namespace std
{
#include <iostream.h>
}

although that's not necessarily how it's written.

David Thornley
Actually, there's often a *lot* more difference than that -- the streams in iostream.h typically weren't templates like they are in iostream. If you do much beyond simple reading and writing (e.g., write any manipulators) the difference is often substantial.
Jerry Coffin
@Jerry: You're right, but unfortunately you're bringing back memories of a system I had to convert that had some ill-documented wizardry done on the streams. However, that doesn't necessarily mean there's a significant difference between iostream.h and iostream in a modern implementation. If I remember, I'll look at my gcc implementation when I get home.
David Thornley
@David: yes, that why I commented elsewhere that the differences between iostream and iostream.h vary widely. In some, iostream.h is a current implementation, with `using` declarations for all the contents. In other cases, it's an old implementation (and in a few, something in between...)
Jerry Coffin