Advertisement

<iostream> and <iostream.h> - the difference

Started by August 21, 2002 05:04 AM
2 comments, last by Ilthigore 22 years, 2 months ago
I have seen everyone saying things like: "use , not " " is a degraded header and should not be used" etc.... Here''s my question:- What is the difference??? Everything i use for also works with . The only difference I notice is that with I have to use the namespace thing but I don''t. I must be missing something here as surely "iostream" as a type "file" is somehow linked to the header "iostream.h". I will have a read through both files later and try to spot some differences but I just wonder why, despite my whole good selection of C++ books and tutorials telling me to use , using instead. Are there extra functions or stream capabilities in the other header? I''m not trying to be awkward but I''m just curious?
>>>>>>>>>>>>>>>>>Ilthigore<<<<<<<<<<<<<<<<<
The C++ Libraries including iostream.h existed years before the C++ Standard has been completed. Namespaces were added to the standard very late, and so many older libraries didn't use the std namespace. But as backward compatibility to existing code is a major point in the standard, the standard committee decided to put the library using namespace std into different headers, just without the extension.
This means, if you include iostream.h, you actually include the pseudo standard library. Including iostream means including the Standard C++ Libary. There may be some minor differences between them as some features were added and some were removed during standardization, but the major difference is the namespace.
Oh, and some standard things like "vector's element access time must be constant" might not be implemented in the older libraries.

__________________
Oregon Ghost
---
Wenn NULL besonders gross ist, ist es fast schon wie ein bisschen eins ;c)

if NULL is very big, it is almost like a little ONE.

[edited by - OregonGhost on August 21, 2002 6:36:48 AM]
__________________Oregon Ghost---Wenn NULL besonders gross ist, ist es fast schon wie ein bisschen eins ;c)if NULL is very big, it is almost like a little ONE.
Advertisement
There are a number of issues, differences in the interface (find the right documentation!) and so on... But one of the biggest differences is that iostream.h is char*-based, while iostream is std::string-based. Which, among other things, hids the memory management issues you have to deal with in the iostream.h case, and also supports Unicode streams (std::wstring).

Issues are similar with fstream/fstream.h, strstream/sstream



Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote: Original post by OregonGhost
Oh, and some standard things like "vector''s element access time must be constant" might not be implemented in the older libraries.

I sincerely doubt that.

"We should always be disposed to believe that that which appears white is really black, if the hierarchy of the Church so decides."

Ignatius Loyola, founder of the Jesuits
--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