Thread: <iostream.h> or <iostream> ??

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    26

    <iostream.h> or <iostream> ??

    what the difference between them?!
    i know when we write <iostream> we have to put:
    using std::cout;
    using std::cin;
    and so on, but is there any other difference?!

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    <iostream.h> and the old style headers are deprecated under the c++ standard.......so they are legal, but wond be supported in the future........try to stick with <iostream>

  3. #3
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Follow the c++-standard and use
    Code:
    #include <iostream>
    Itīs more portable. E.i different compiler use different file-extentions (for header files) and if you use #include this way you your code will not be "compiler-dependet".
    Last edited by ripper079; 11-18-2002 at 09:59 AM.

  4. #4
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Re: <iostream.h> or <iostream> ??

    Originally posted by Lazy Student
    what the difference between them?!
    i know when we write <iostream> we have to put:
    using std::cout;
    using std::cin;
    and so on, but is there any other difference?!
    Fordy is correct its about that darn ISO/ANSI standards. <iostream> is thee newest and its technically correct vs. the other even though both are correct.

    In a nutshell...one is outdated as far as stardards and the ohthwer isnt.

    Hope this helps!
    cj
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    20
    whats really the point of changing it if it worked fine before? i mean, does it really matter that you have ".h" after iostream? or is there something else that it does?

  6. #6
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    <iostream.h> is considered depreciated under modern C++. the only difference between the two is that the members of <iostream> are declared in the namespace std where as the members of <iostream.h> are declared outside of namespace (because <iostream.h> is from an earlier era where namespaces did not exist)
    hello, internet!

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    20
    oh, ok. it has <iostream.h> on the tut at the cprogramming site, so it must have been written a little while ago i guess.

  8. #8
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    namespace std is not the only difference. There are other more subtle differences.
    Use the newer header if your compiler has it. If not get a new compiler.The old .h headers are their for legacy code compatability thats all.Treat them as if they are not meant for use in c++. Eventually support for the old style headers may be dropped then compilers will not have to provide them.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  9. #9
    CIS and business major
    Join Date
    Aug 2002
    Posts
    287
    <iostream> is the newer version, and you can more easily use it by doing this:

    #include <iostream>
    using namespace std;

    and you can use it the same as <iostream.h>.

    From what I heard, they created the updated <iostream> to ........ off microsoft, windows gui users can't double click on a file without an extension.

    And they kept iostream.h so compilers would be compatible and be able to compile code using it with the .h extension.

    but the two are different, just check the source.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. <iostream> <stdio.h>
    By hero_bash in forum C++ Programming
    Replies: 13
    Last Post: 06-24-2006, 04:56 PM
  2. <iostream.h> or <iostream>?
    By {MaX} in forum C++ Programming
    Replies: 18
    Last Post: 06-05-2006, 12:52 AM
  3. <iostream.h> or <iostream>?
    By Yumin in forum C++ Programming
    Replies: 30
    Last Post: 01-31-2006, 02:00 AM
  4. <iostream> over <iostream.h>
    By GreenCherry in forum C++ Programming
    Replies: 10
    Last Post: 10-16-2002, 11:37 AM