473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

#include <iostream.h> or <iostream>

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
10 89305
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
"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
#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

"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
#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


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
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
"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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: ai | last post by:
Hi , I have an application which has to read files of size few mba nd read them into array . Since i am using STL and std namespace to avoid the error error C2872: 'ifstream' : ambiguous...
1
by: zerotyNONONOTHERESNOSPAMMING!type | last post by:
Hi, As most of you probably already know, depending on which implementation of C++ you have, #include <iostream> may cause various other headers to be #included too. (I've observed cstring,...
1
by: ya man | last post by:
when i use #include <iostream.h> in some files i get lots of error messages of the kind 'ambiguous symbol this is solved when i use #include <iostream why is that ? and can i use #include...
2
by: Brett | last post by:
Hi, I'm compiling an old project under the 'new' visual studio 7.1.3088. I changed the line: #include <iostream.h> to #include <iostream> and now I get a stack of errors, some of which...
9
by: nichas | last post by:
I tried to use #include<iostream> in visual C++ compiler but then it didnt work but i see this is the way it is being mentioned in C++ primer by lippman and lajoie.. where is the problem.. Do...
5
by: wesley | last post by:
Hi All. i am new to C++. I know that in order to use cout, i need to include <iostream>. I have done this, but i still get errors when i try to output to the screen. Is there a file that needs to...
1
by: lars.uffmann | last post by:
Hello everyone! I just debugged a pretty huge project, eliminating basically every memory leak that would occur with the current configuration files, at least according to the mtrace() tool from...
1
by: Old Wolf | last post by:
In a discussion elsewhere, someone wrote: #include <iostreamis not guaranteed to define std::cout, it merely has to declare it as an extern object, and declarations of extern objects do not...
11
by: gumboots | last post by:
Hi there guys, I've recently purchased "Sam's Teach Yourself C++ Fifth Edition" (About a week before the 6th edition came out) I'm trying to work through the book, but in trying to compile Hello...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.