<iostream> over <iostream.h>

This is a discussion on <iostream> over <iostream.h> within the C++ Programming forums, part of the General Programming Boards category; What is the point of including files without using ".h"??...

  1. #1
    Registered User GreenCherry's Avatar
    Join Date
    Mar 2002
    Posts
    65

    Angry <iostream> over <iostream.h>

    What is the point of including files without using ".h"??
    I have a rabbit in my pants! Please be happy for me.

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    160
    It's what is reffered to as the header files and they in turn include the cpp file.
    Last edited by Zahl; 10-14-2002 at 09:43 AM.
    Well english isn't my first language, (it's instead a useless language called danish which only 5 milion people speak!!) so if you think my grammar SUCKS (it does by the way) than you're more then welcome to correct me.
    Hell I might even learn something

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    iostream is part of the C++ standards recommended headers....iostream.h was implemeted before the standard, but not all versions in compilers of the time were wrapped in namespace std....so therefore they could have proposed all future implementations should be in std:: (in which case lots of legacy code would need to be rewritten for use on standard complient compilers) - and that wouldnt have been popular!!!

    They went a completely different way and proposed a seperate header that provided all the same functionality of iostream.h, but wrapped it in namepsapce std..(this was <iostream>)

    You can still use iostream.h, but it has been deprecated and should only be used for legacy code

  4. #4
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    When i use my MSVC++ 6.0 std edition it doens't let me not use the .h....

  5. #5
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    "When i use my MSVC++ 6.0 std edition it doens't let me not use the .h...."

    It does, except that the whole standard library is in namespace std.

    Code:
    #include <iostream>
    int main() {
        std::cout << "Look Ma, standard compliant C++ code" << std::endl;
        return 0;
    }
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  6. #6
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    ok, thnx for the clarification.

  7. #7
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    I use the #include<iostream>
    and then add
    using namespace std;

  8. #8
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Is the difference that iostream is devided into classes like std and ios ???

    Thanks for help.

  9. #9
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    If you don't want to #include the whole std namespace when using <iostream> or other #includes w/o the .h, include only the parts your program uses.
    Code:
    #include <iostream>
    using std::cout;
    using std::cin;
    // etc, instead of using namespace std;
    This allows you to avoid SilentStrike's method of having to prefix every use with std::, which is perfectly valid, but which seems awkward to me.
    Truth is a malleable commodity - Dick Cheney

  10. #10
    Registered User
    Join Date
    Dec 2001
    Posts
    88
    Originally posted by ammar
    Is the difference that iostream is devided into classes like std and ios ???
    No!
    in <iostream> everything is in the namespace std. std is a namespace, not a class!

    ios is a typedef to hide ios_base! (which is a class)

    But there are more differences - the implementation of <iostream> is much newer than <iostream.h>.

    I don't know exactly where the differences are, but I think I read a good article at cuj.com
    Hope you don't mind my bad english, I'm Austrian!

  11. #11
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Originally posted by ammar
    Is the difference that iostream is devided into classes like std and ios ???

    Thanks for help.
    Theoretically <iostream> should conform to the standard on C++ compilers, while <iostream.h> is deprecated so can be just about anything.....

    But practically, compiler vendors usually implement the iostreams in one way and provide one header in namespace std, and the other in global scope...so they most likely represent the same functions.

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, 01:00 AM
  4. <iostream.h> or <iostream> ??
    By Lazy Student in forum C++ Programming
    Replies: 8
    Last Post: 11-18-2002, 07:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21