473,249 Members | 1,427 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,249 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 89275
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.