Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


What's the difference between #include "iostream.h" and #include <iostream>?

Posted on 2004-11-01
Medium Priority
Last Modified: 2013-12-14
Sometimes we see

#include "iostream.h"

and other times we see

#include <iostream>

What is the difference?
Question by:baltmann
  • 3

Expert Comment

ID: 12464729
If you write #include <iostream.h> you get the legacy.
 If you write #include <iostream>"you get the standard stuff.
 If you write #include "iostream.h" - searches for the file in subdirectories on your system.

Normally for iostream you would not use "iostream.h"

Author Comment

ID: 12464836
That's good. Could you elaborate more on "the legacy" and "the standard stuff" please.

Assisted Solution

by:Hamed Zaghaghi
Hamed Zaghaghi earned 80 total points
ID: 12465010

before 1999, this include is true that use the header name with .h, that in some compiler like VC++ 6 works, but after 1999 in ANSI startndard this include and other standard includes, must use with out .h and must use "using namespace std;" to use these standard headers.

like this:
#include "iostream"

using namespace std;

have a good including day;

Accepted Solution

pb_india earned 720 total points
ID: 12465678
iostream.h> is pre-standard C++, so it's 'old fashioned'.

<iostream> is standard C++, in which the standard library is in namespace std.

If you use the latter (which you ought to if your compiler supports it) then you'll need to qualify entities from the standard library in one of the following ways:

[1] using directive:

using namespace std;

[2] using declaration:

using std::cout;
using std::endl;

[3] namespace prefix:

std::cout << "hello world" << std::endl;


Expert Comment

ID: 12465700
using .h is C style. in C++ you should use <iostream>
Historically, <iostream.h> and similar header files are older than <iostream>. What happened is that early version of C++ provided a library, and header files such as <iostream.h> declared the various classes, operations, etc.

During the process of producing the C++ standard, a lot of features were added to the language. Such as exceptions, namespaces, the bool type, etc etc. Language features associated with templates were also radically improved. One consequence of that was that those developing the standard realised that the existing "standard" library was clunky compared with the language itself. So, the libraries were revamped. The STL was designed, and then attention was focused on basic things such as I/O. One of the core decisions was that things should be put into a specific namespace if at all possible, and the std namespace came into existance. When it was pointed out that this would mean a problem keeping backward compatibility with older C++ code (that used iostream.h, etc), it was realised that a different set of #include <> names were needed. What it boiled down to was that everything in the C++ standard library (streams, the STL, etc) were placed in header files without a .h extension, and a new set of header files to provide C library functions (prefixed with c, such as <cstdio>) to allow for the fact that C standards would evolve independently, but allow a particular set of accepted C functions to be frozen in C++.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question