<iostream.h> and <iostream>

Started by
11 comments, last by mokermachine 21 years ago
This may sound stupid (I''m a newbie) but what is the difference between #include <iostream.h> & #include <iostream>
Advertisement
iostream.h is the pre-standard version of iostream.

iostream is right, iostream.h is wrong. Don''t use iostream.h
The newer C++ header files are the ones without the h. This includes the STL template classes. The main difference is that all the functions and constants are in the std namespace, to avoid global namespace polution and potential conflicts with legacy code. To summarize, you should not use the .h; its deprecated.
quote:Original post by invective
you should not use the .h; its deprecated.

If you''re ever stuck for something to say at cocktail parties, try this one... To be deprecated, it has to have been part of the Standard to begin with. iostream.h never was part of the C++ Standard.
The same goes for many other header files (cstdio, cstring, etc), does it not? I usually use the .h-less versions, unless I''m feeling too lazy to care.

Why did they ever get used if they were never included in any standard? And why is the MSDN help full of the .h versions?

Harry.
Harry.
quote:Original post by HarryW
Why did they ever get used if they were never included in any standard?


What an interesting question.
quote:Original post by SabreMan
To be deprecated, it has to have been part of the Standard to begin with.

Does it? Webster says the verb "deprecate" means "to express disapproval of". It says nothing to the effect of that the subject in question has to have been formally standardized.
quote:
iostream.h never was part of the C++ Standard.

It was never part of a formal C++ Standard. But doesn''t the ARM, which I believe constituted a de facto standard back in the days, describe it?


"Laughter means distance. Where laughter is absent, madness begins. The moment one takes the world with complete seriousness one is potentially insane. The whole art of learning to live means holding fast to laughter; without laughter the world is a torture chamber, a dark place where dark things will happen to us, a horror show filled with bloody deeds of violence."
-- Jens Bjørneboe
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
quote:Original post by Arild Fines
Does it? Webster says the verb "deprecate" means "to express disapproval of".

The C++ Standard says...
quote:
[...] deprecated is defined as: Normative for the current edition of the Standard, but not guaranteed to be part of the Standard in future revisions.

quote:
It says nothing to the effect of that the subject in question has to have been formally standardized.

I''d hazard a guess that''s because Websters doesn''t define the C++ language and associated terms.
quote:Original post by HarryW
The same goes for many other header files (cstdio, cstring, etc), does it not?

No. Those headers (the "stdio.h" form that is) are part of the C89 Standard and are included into the C++98 Standard by reference.
quote:
Why did they ever get used if they were never included in any standard?

Because C++ existed for several years before it got an ISO Standard.
quote:
And why is the MSDN help full of the .h versions?

Because it contains out-of-date information. And because MS provide an iostream.h header, so can guarantee it's presence (which ISO cannot).


[edited by - SabreMan on April 18, 2003 9:04:03 PM]
VC++7.0(and upwards, I assume) gives you compilation warnings when including the .h headers, though.


"Laughter means distance. Where laughter is absent, madness begins. The moment one takes the world with complete seriousness one is potentially insane. The whole art of learning to live means holding fast to laughter; without laughter the world is a torture chamber, a dark place where dark things will happen to us, a horror show filled with bloody deeds of violence."
-- Jens Bjørneboe
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

This topic is closed to new replies.

Advertisement