![]() |
#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 |
Re: #include <iostream.h> or <iostream>
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 |
Re: #include <iostream.h> or <iostream>
"John Tiger" <umalme@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 |
Re: #include <iostream.h> or <iostream>
#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" <umalme@hotmail.com> wrote in message news:587438f2.0308041108.2560c371@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 |
Re: #include <iostream.h> or <iostream>
"Wawa" <S.C.Clough-98@student.lboro.ac.uk> wrote in message news:dmyXa.20409$Id1.2066936@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 |
Re: #include <iostream.h> or <iostream>
> > #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 |
Re: #include <iostream.h> or <iostream>
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 kbuchegg@gascad.at |
Re: #include <iostream.h> or <iostream>
>>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 > > |
Re: #include <iostream.h> or <iostream>
"Noah Roberts" <nroberts@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 |
Re: #include <iostream.h> or <iostream>
"Web Developer" <nospam@hotmail.com> wrote in message news:<3f2f832e_1@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? |
| All times are GMT. The time now is 03:49 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.