I was reading another thread where a guy asked about C++ books for beginners, and one of the programmers answering wrote this:

Some warnings: avoid all books that present an "hello world" stating with

#include <iostream.h>

I opened my C++ book and sure enough it included the iostream header like the example above.

Why is that bad? What other pointers should I keep in mind when learning C++?

Background: I am proficient with C and I'll start to learn C++ this next semester.

  • 3
    Another, related pointer, is to include cstdio, not stdio.h (the latter is deprecated). Dec 26, 2011 at 17:25
  • 7
    @AntonGolov Opinions differ. Many experts prefer <stdio.h> as there is no technical reason why <cstdio> should be prefered.
    – Sjoerd
    Dec 26, 2011 at 22:59
  • 2
    @Sjoerd The fact that <cstdio> is guaranteed to provide the names in namespace std is reason enough for me to prefer it. I know that it might also provide them in the global name-space just as <stdio.h> might provide them in namespace std. It is also a matter of consistency if you make it a habit to always use the <c…> headers. And for some headers, you'll really want this because they enhance the C interface with additional function overloads, for example.
    – 5gon12eder
    Oct 8, 2015 at 0:35

4 Answers 4


The header iostream.h is a non-standard header and does not exist on all platforms. As a matter of fact it does not exist on my system (using g++ and the GNU libstdc++). So any code using it would simply not compile on my system.

The iostream.h header used to be common before C++ was first standardized in 1998. But since the 98 standard used <iostream> instead of <iostream.h>, the latter has fallen out of favor (being non-standard and all) and is no longer supported on all platforms. Code that uses it should be considered non-standard legacy code and is not portable. Books that teach it should be considered outdated and avoided.

  • 14
    I wouldn't avoid a book outright just because of a trivial preprocessor syntax issue. It could be a great book while a terrible book could be using the modern syntax.
    – Lord Tydus
    Dec 26, 2011 at 13:19
  • 21
    @Lord Tydus The fact that any given pre-98 book could be a great book does not negate the fact that statistically, you would be better off avoiding pre-98 books.
    – Mike Nakis
    Dec 26, 2011 at 13:33
  • 12
    @LordTydus: Totally disagree. The style and usage of C++ is not the same as in 98 thus it is not just fixing syntactic issues. Dec 26, 2011 at 18:00
  • 7
    @LordTydus If the old syntax plain and simply does not compile on modern compilers, you'll have a hard time using a book that teaches the old syntax. Note that any book that teaches the usage of iostream.h almost certainly doesn't teach e.g. namespaces either, so even after replacing iostream.h with iostream, your code won't work. If you have to google or ask for help on SO every time you want to compile an example from the book, that's not a very effective way to learn C++.
    – sepp2k
    Dec 26, 2011 at 21:47
  • 3
    @LordTydus: In general, I've found that books that use headers like that tend also to use bad practices and are riddled with errors. I've taken to collecting such books just to keep them out of circulation.
    – greyfade
    Dec 27, 2011 at 17:09

#include <iostream.h> is a sign that the book was written prior to the first C++ standard in 1998 (the standard header is iostream).

The problem is that older C++ code tends to be written in ways that are considered bad practice today. In particular,

  • The use of C-style arrays rather than container classes like std::string and std::vector.
  • The use of explicit close functions rather than RAII.

iostream.h isn't the worst thing a pre-1998 book will get wrong, but it's likely to be the first thing that a pre-1998 book will get wrong.


Maybe this comes a bit late but for what it's worth, on a unix/linux box do ls /usr/{local/,}include/c++/* or similar, according to your layout and paths. You could pipe to grep looking for the header in question, like:

ls /usr/{local/,}include/c++/* | grep iostream 

This entails a look-up for iostream.h as well as any other superstrings.

Or run find / -type f -name iostream 2> /dev/null | grep include or locate iostream | grep include (provided the database is current, otherwise prepend with a call to updatedb)--these, however, will print also non-system-wide includes, so please adjust appropriately. The actual C++ include path is easily found with something like:

g++ -v 2>&1| sed -rn 's/.+gxx-include[^=]+=([^ ]+).+/\1/p' # adjust iff empty

Equivalently on Windows and other machines. I guess the idea is clear--such a file as iostream.h doesn't exist in the system include path by default any longer, you still, however, can find legacy libc++ distributions with iostream.h either soft-linked to iostream or as its copy. So this is not a matter of style but rather of the circumstances. You could ship your own iostream.h with your project just make sure it's contained in the include path where your compiler looks up for the <...> headers.

  • 1
    Very practical but doesn't really address the real fundamental point. Jan 11, 2014 at 17:12

Just dropping my 2 cents. I don't think there is a correlation between ".h" and the quality of a book. This is a minor syntax issue. Back in the day it was actually the correct sytnax.

Is it possible to have a great book with iostream.h? yes

Is it possible to have a terrible book with iostream? yes

I would rely on online user reviews (and my own review after reading) to judge the quality of a book.

  • 5
    Is Lisp outdated because it's from 1958? We utilize Pythagoras's work in every modern missile system even though the math is thousands of years old. In the current C++ book market the ".h" books may well be terrible. But it is a quality of book issue, not a ".h" issue. ".h" isn't even programming logic, it's for the preprocessor.
    – Lord Tydus
    Dec 26, 2011 at 13:50
  • 5
    but will someone learning the language for the first time know when the book is telling them something wrong? How much time and frustration will they go through before finding out that the ".h" is now incorrect? And in how many other ways is the book out of date? Dec 26, 2011 at 16:27
  • 24
    The trouble is the usage of C++ has changed significantly since those books were written. The whole way you think and use C++ is not the same as those books will present as they do not have any of the facilities that modern C++ has. As a result you will be teaching yourself C with classes not C++. Dec 26, 2011 at 17:58
  • 4
    This has nothing to do with "syntax" whatsoever. Jan 11, 2014 at 17:12
  • 4
    -1. As @LightnessRacesInOrbit points out, this isn't a simple syntactic issue. The change from <xxxx.h> to <xxxx> was done for a very important reason: to maintain backwards compatibility for code that doesn't use namespaces when the facility was introduced and the standard library was moved into the std namespace. You can therefore be confident that a book using <iostream.h> doesn't teach this critical feature of the language, and is therefore so incomplete as to be virtually useless.
    – Jules
    Oct 8, 2015 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.