By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,889 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,889 IT Pros & Developers. It's quick & easy.

#include <iostream.h> or <iostream>

P: n/a
Can anybody have idea about the difference between #include
<iostream.h> and
#include <iostream>. Is later one valid statement on any compiler. I
tried compiling on MSVC second statement give compilation error as
#include expect filename.

Anu help would be appreciated.

thanx,
John
Jul 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
John Tiger wrote:
Can anybody have idea about the difference between #include
<iostream.h> and
#include <iostream>. Is later one valid statement on any compiler. I
tried compiling on MSVC second statement give compilation error as
#include expect filename.

Anu help would be appreciated.

thanx,
John


For newer versions of gcc (3.x I think) iostream.h is deprecated. I've
always used iostream.h when dealing with ms and mipspro.

-Otto

Jul 19 '05 #2

P: n/a
"John Tiger" <um****@hotmail.com> wrote...
Can anybody have idea about the difference between #include
<iostream.h> and
#include <iostream>. Is later one valid statement on any compiler. I
tried compiling on MSVC second statement give compilation error as
#include expect filename.


<iostream> is a standard header where certain objects are declared.
<iostream.h> is its obsolete incarnation, it has never been standard
and existed in pre-standard era only.

There is no requirement in the Standard that headers should exist in
a file form.

#include <iostream>

is a standard way to incorporate the declarations of those certain
objects into your code. It is valid on all compilers that are
Standard-compliant.

Questions on MSVC should be asked in microsoft.public.vc.language.
It is quite possible that the version you have is too old to be at
all compliant (released before the language was standardised, for
example).

Victor
Jul 19 '05 #3

P: n/a
#include <iostream> is the Standard C++ way to include header files, the
'iostream' is an identifier that maps to the file iostream.h. In older C++
you had to specify the filename of the header file, hence #include
<iostream.h>. Older compilers may not recognise the modern method, newer
compilers will accept both methods but the old method is obsolete.

iostream.h became iostream
fstream.h becams fstream
vector.h became vector
string.h became sting etc.

"John Tiger" <um****@hotmail.com> wrote in message
news:58**************************@posting.google.c om...
Can anybody have idea about the difference between #include
<iostream.h> and
#include <iostream>. Is later one valid statement on any compiler. I
tried compiling on MSVC second statement give compilation error as
#include expect filename.

Anu help would be appreciated.

thanx,
John

Jul 19 '05 #4

P: n/a

"Wawa" <S.***********@student.lboro.ac.uk> wrote in message
news:dm*********************@newsfep2-win.server.ntli.net...
#include <iostream> is the Standard C++ way to include header files, the
'iostream' is an identifier that maps to the file iostream.h. In older C++ you had to specify the filename of the header file, hence #include
<iostream.h>. Older compilers may not recognise the modern method, newer
compilers will accept both methods but the old method is obsolete.

iostream.h became iostream
fstream.h becams fstream
vector.h became vector
string.h became sting etc.


Not true.

string and string.h are both standard header files that do completely
different things.

The other .h files are non-standard, it is not the case a compiler will
accept both.

john
Jul 19 '05 #5

P: n/a
#include <iostream> is the Standard C++ way to include header files, the
'iostream' is an identifier that maps to the file iostream.h. In older

C++
you had to specify the filename of the header file, hence #include
<iostream.h>. Older compilers may not recognise the modern method, newer compilers will accept both methods but the old method is obsolete.

iostream.h became iostream
fstream.h becams fstream
vector.h became vector
string.h became sting etc.


Not true.

string and string.h are both standard header files that do completely
different things.

The other .h files are non-standard, it is not the case a compiler will
accept both.

john


I just like to add that the .h extension denotes a C header file, while the
..hpp extension denotes a C++ header file. Maybe someone can clarify this?.

Side note: I assume a header file is like the import statement in Java?

WD
Jul 19 '05 #6

P: n/a


Web Developer wrote:
#include <iostream> is the Standard C++ way to include header files, the
'iostream' is an identifier that maps to the file iostream.h. In older C++
you had to specify the filename of the header file, hence #include
<iostream.h>. Older compilers may not recognise the modern method, newer compilers will accept both methods but the old method is obsolete.

iostream.h became iostream
fstream.h becams fstream
vector.h became vector
string.h became sting etc.


Not true.

string and string.h are both standard header files that do completely
different things.

The other .h files are non-standard, it is not the case a compiler will
accept both.

john


I just like to add that the .h extension denotes a C header file, while the
.hpp extension denotes a C++ header file. Maybe someone can clarify this?.


You need to understand that the extension is just a convention.

Whatever filename you plug into

#include "whatever"

will be pulled in by the preprocessor.
Side note: I assume a header file is like the import statement in Java?


It is an order to the preprocessor to replace the line containing #include
with the actual content of the specified file. Nothing more, nothing less.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 19 '05 #7

P: n/a
string.h became sting etc.
Not true.

string and string.h are both standard header files that do completely
different things.


I thought that the current standard called string.h cstring to avoid
ambiguity. "string.h" is a standard header file in C, but I didn't
think it was supposed to be used by the C++ standard.

The other .h files are non-standard, it is not the case a compiler will
accept both.

john

Jul 19 '05 #8

P: n/a
"Noah Roberts" <nr******@dontemailme.com> wrote...
string.h became sting etc.

Not true.

string and string.h are both standard header files that do completely
different things.


I thought that the current standard called string.h cstring to avoid
ambiguity. "string.h" is a standard header file in C, but I didn't
think it was supposed to be used by the C++ standard.


It's used for compatibility reasons along with 17 other C headers.

Victor
Jul 19 '05 #9

P: n/a
"Web Developer" <no****@hotmail.com> wrote in message news:<3f********@news.iprimus.com.au>...
I just like to add that the .h extension denotes a C header file, while the
.hpp extension denotes a C++ header file. Maybe someone can clarify this?.
This is convention, but you'll see a ton of headers with C++-only
constructs in .h files as well. There are also other conventions that
are less common; instead of .cpp sometimes .C (if you have a case
sensitive filesystem) or .cxx or even .c++ if your filesystem supports
that filename are used, and the corrosponding .H, .hxx, and .h++ are
also occasionally seen.
Side note: I assume a header file is like the import statement in Java?


They are somewhat similar, but there are significant differences.
import only pulls some names into scope, for instance with an import
javax.swing.* you'll only have to use the identifier JPanel instead of
javax.swing.JPanel. In this sense it's like a using statement. (I
chose "statement" to leave the exact meaning ambiguous; the above
import is like a using directive, while if i had said import
javax.swing.JPanel that's analogous to a using declaration.)

#include <filename> and #include "filename" actually put the contents
of filename into the current file. This is necessary because there is
(thankfully IMO) no way of knowing where the compiler (or VW in the
case of Java) should go to find things if I just write the following
C++ file:

int main () {
std::cout << "Hello mars!\n";
}

It doesn't know about the namespace std or the object std::cout.
Whereas if I write a similar Java program

class neededClass {
static int main() {
System.out.writeln("Hello mars!\n");
}
}

it knows where to find System, then System.out because of the standard
naming scheme.

Does that help?
Jul 19 '05 #10

P: n/a
ghl
"Karl Heinz Buchegger" <kb******@gascad.at> wrote in message
news:3F***************@gascad.at...
<<snip of good answer by Karl>>
Side note: I assume a header file is like the import statement in Java?


It is an order to the preprocessor to replace the line containing #include
with the actual content of the specified file. Nothing more, nothing less.


And just to complete it: No, a header file is not like import statement in
Java. import statement in Java is more like using.
--
Gary
Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.