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

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    But I don't have any problem with my compiler, I like it! I think it is not a problem for a compiler to compile a code, the problem is when it doesn't.
    The problem is that your current compiler is outdated and thus not standards compliant. So yes, you will find that your compiler will be unable to compile standards compliant code in some cases, especially if they use advanced constructs not previously widely supported.

    EDIT:
    Well, I took a look at the features listed in MS Visual C++ 2005, and on the "Powerful Language and Libraries" page there is the claim:
    "Earlier versions of Visual C++ didn’t support the advanced C++ features required to successfully compile some of these libraries. Now, with Visual C++ 2005’s improved ISO compliance, it is very easy to incorporate code from these libraries."

    The library examples being Loki, Boost, Blitz and Crypto++, boost in particular being very useful.
    Last edited by laserlight; 01-29-2006 at 01:08 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    <iostream.h> is provided by most compilers for backwards compatibility only. As far as I'm aware it's basically the same as <iostream> but without the namespace support.
    Similar for the others.

    It's not recommended to be used in new code of course.

  3. #18
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> I don't know a single modern C++ compiler that won't compile <iostream.h>
    The OP already indicated that VC++ 7 (2003) won't compile <iostream.h>. It doesn't even give you a helpful error message.

    >> If it compiles then it's OK.
    You made the decision to use the old headers because it works on your compiler. That doesn't mean it is the proper decision to advise other programmers to follow. Many people here cannot help you because they use VC++ 2003 or 2005 and your examples don't compile. It is a very simple change to use the correct headers, even in VC++ 6, and so not doing so just gives the impression that you would prefer to save yourself a single line of typing over making it easier on those who are trying to help you. Besides, purposefully choosing the old way that is no longer being supported when you can use the new way right now without changing your compiler is the type of decision that leads towards a poor career as a programmer.

  4. #19
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    Actually I use old headers because I don't know what "name space" exactly is. And I wont use what I don't know. But finally I'll learn it (i hope), and will use it.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  5. #20
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  6. #21
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    Tnx SirCorno6
    If iostream.h is an iostream without namespace why a new compiler can't compile it?
    Even if iostream.h is older it is in standard c++ , shouldn't it compile?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  7. #22
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Lol, theyse programming holy wars happen all to often .

    Just use the basic <iostream> using namespace std; Otherwise your compiler will probably get mad .
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  8. #23
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> If iostream.h is an iostream without namespace why a new compiler can't compile it?

    That's not necessarily true. Some compilers will do that for iostream (like VC++ 6), but there are often differences between the standard iostream stuff and what each compiler vendor used to do in their version of iostream.h.

  9. #24
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    >>you would prefer to save yourself a single line of typing over making it easier on those who are trying to help you.

    Why? I only used old iostream.h anybody can change it to iostream (press backspace twice) and add "using namespace std;" it should not bother anybody, does it? If I used another old header, please inform me.

    Is this true that iostream and iostream.h both use stdio?
    If no, why stdio.h is included in them?
    I took a look into both iostream and iostream.h. They were completely different (in design)and iostream.h was more understandable, stdio.h was included in both(not in the file itself but in one of deeper included headers). They each use their own headers (ex. ios vs ios.h), but there was also useoldio.h in iostream.h. That file force code to use classic iostream libraries.
    Last edited by siavoshkc; 01-30-2006 at 01:45 AM.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  10. #25
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > I took a look into both iostream and iostream.h. They were completely different (in
    > design)and iostream.h was more understandable, stdio.h was included in both
    Yeah, and so every other compiler will be the same right?
    Not a chance matey.

    Get used to the namespace version would be my suggestion, it's the way the future is going so you may as well get used to it at the outset.

    Anything else is just the "turboC on XP defence"

  11. #26
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    I saw laserlight's link, MVC2005 is like an icecream, I'll get it soon.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  12. #27
    Registered User
    Join Date
    Oct 2005
    Posts
    88
    I'm pretty new to c++ but I can't see why people always say to go for 'using namespace std'. I prefer to put a 'using std::cout' instead (or using std::<iostream function call here>). Just dumping the whole std namespace into all of your files just cuts down the function names you can use, plus if you have a wierd function in the file it's far easier to see that it's from 'std::' if you have it explicitly at the top of your file.

    I wouldn't care, but I get the impression that people say to just go for 'using namespace std' because they somehow think that it makes it easier that way... Whether it does or doesn't, IMHO it's one of the easiest bits of the language to learn so why not start off right?

    That's a genuine question. People here don't just dump the std namespace do they?

  13. #28
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    No. In this case, I think many are saying that it isn't hard to move from <iostream.h> to <iostream>, the least you have to do is add the "using namespace std;".

    However, I personally, use std:: unless I am modifying code that does it a different way (which never happens except when answering questions on forums like this). I just prefer to be consistent, and there are other situations where adding the using directive is somewhat more dangerous (e.g. inside header files). So why not just use the same thing everywhere?

    Another common usage is to put the using directive only inside the block of code that needs it. For example, you could put it inside main() at the very top.

  14. #29
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    People here don't just dump the std namespace do they?
    I think the general rule of thumb is to fully qualify identifier names in header files, and then to use the using declarations for the specific identifiers you want to use in source files.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #30
    Madly in anger with you
    Join Date
    Nov 2005
    Posts
    211
    Quote Originally Posted by Daved
    Another common usage is to put the using directive only inside the block of code that needs it. For example, you could put it inside main() at the very top.
    good idea. never thought of that myself to be honest. that way the namespace goes out of scope when the function does (this wouldn't be beneficial in main(), but could be in other functions).
    Last edited by Bleech; 01-30-2006 at 10:47 PM.

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 Lazy Student in forum C++ Programming
    Replies: 8
    Last Post: 11-18-2002, 08:58 PM
  4. <iostream> over <iostream.h>
    By GreenCherry in forum C++ Programming
    Replies: 10
    Last Post: 10-16-2002, 11:37 AM