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

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    8

    Question <iostream.h> or <iostream>?

    First of all, hi to all members. I'm new here

    I'm very new to C++. The stuff they're teaching us at school (and in the 2 month c++ course I joined in the vacations) uses those "antiquated" header files ( <iostream.h> and all).

    For school, I MUST learn this, I know. But I wanted to ask if not using this new syntax (or whatever) makes any difference? (except those humoungous error messages). Is there any difference b/w the syntax of the new and the old programming? Is ir even right to call one of them "old" and one of them "new"? And, once I've been through my school exams and all, can I learn this STL and all that without re-learning or un-learning old stuff?

    As you see, I'm extremely confused. Please help me out, guys!

  2. #2
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    iostream.h is actually older syntax. you can use iostream because it's a standard C++ library.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The <iostream.h> form was in early draft versions of the C++ standard. It was eliminated in favour of the <iostream> form during the standardisation process.

    Technically, as it never appeared in any formally ratified standard, the <iostream.h> form is completely non-standard. In practice, however, several vendors were implementing C++ compilers to comply with draft standards (some did it to gain a commercial edge earlier, by having a compiler compliant with the draft standard, some vendors did it to provide a proving ground for the standardisation process). What that means is that several older compilers, from several vendors, support features that were in draft C++ standards but eventually removed. <iostream.h> is one of those.

    While it is probably accurate to describe <iostream.h> as old (as it is supported by old compilers and their libraries) vs the new <iostream>, it is more correct to describe <iostream.h> as pre-standard or (if you want to be picky) non-standard and <iostream> as standard.

    In terms of content, the main difference between <iostream.h> and <iostream> is that (almost?) everything in <iostream> lives in namespace std. There are some other differences as well, but those are minor changes to function names, argument lists, the behaviour of some function, etc. In fact, some vendors support <iostream.h> as essentially a wrapper of <iostream> (and some do that in reverse, with <iostream> wrapping <iostream.h>). That tends to introduce some small incompatibilities that bite (mostly) programmers using the <iostream.h> form.

  4. #4
    Registered User
    Join Date
    Jun 2006
    Posts
    8
    Well, at my school they teach <iostream.h>. If the differences aren't too big then can I learn the "standard" version of C++ later? I mean to say, it won't be a BIG transition will it?

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Well, at my school they teach <iostream.h>.
    Well do they insist you use some crappy old compiler to go along with that as well?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    > If the differences aren't too big then can I learn the "standard" version of C++ later?
    No, learn it now. The differences between <iostream.h> and <iostream> are big! Grumpy's post is pretty thourough on the reasons why <iostream.h> is such a waste of people's time.
    > I mean to say, it won't be a BIG transition will it?
    Not really a big transition, no. You will still find cout and stuff in there, and the plethora of references available to you will help you.

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Salem
    > Well, at my school they teach <iostream.h>.
    Well do they insist you use some crappy old compiler to go along with that as well?
    That's actually a good question.

    If you're being forced to use <iostream.h> then your school has one of two problems;

    1) A teacher who learnt the <iostream.h> form, and is not willing to update his/her knowledge so he/she can teach current material. <iostream.h> is one of several things that are ten (or so) years out of date. This is a political issue (the main barrier is the teacher's willingness to update knowledge rather than insisting that what s/he is doing is C++). If you have a teacher like this, you have no way around the issue other than learning <iostream.h> and then learning <iostream> later. Keep in mind that this issue is the tip of the iceberg: <iostream.h> is just the most obvious of many little changes with the C++ language and library: you will be taught several techniques that are no longer relevant. The most common reason that a teacher will resist updating is the effort involved: it takes time to learn the differences and (for the teacher) more time to update course notes, presentation material, etc etc.

    2) A school that is using an old compiler. Technically, there is no real reason for this, as there are now good quality compilers and development environments available free. Or, at worst, at quite low cost when you consider academic discounts. This one is technically surmountable (it is not difficult to get a modern compiler and install it) but may not be politically surmountable (eg a teacher or an IT department who insist on using an old compiler).

  8. #8
    Registered User
    Join Date
    Jun 2006
    Posts
    8
    It's not about school. I live in India and back here CBSE (Central Board of Secondary Education) and ICSE tell the schools what to teach. They tell them which books to use and what is to be taught. So, it looks like the whole country is learning <iostream.h> coz everyone uses the old syntax with Turbo C++ (v3.something!!).

    Looks like I might have to write a letter to the president ;-)

  9. #9
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Note to self: when contracting out C++ development work, do not go to India if standard compliance is important.

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Looks like I might have to write a letter to the president
    Please do, so that grumpy wont be so grumpy about contracting out C++ development work to your countrymen.

    But yeah, when I was in junior college not long ago (2002-2003), my school used MSVC6 with <iostream.h>
    Now my sister is using the same thing. I've considered writing to the education ministry in Singapore to recommend that they use MSVC8 since MS Visual Studio C++ 2005 Express is available at zero price... but then they probably will consider it not worth the trouble to change.
    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

  11. #11
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Wow - that's the most revealing 3 lines of text I've seen it a long while MaX, thanks.
    It explains SO much about why those old fossil compilers remain popular, it's because their use is institutionalised.
    It also explains why whenever I see a nickname which looks even remotely Indian, that it's a safe bet that they're using TurboC.

    It also seems they go in for teaching the compiler, rather than teaching the language, which further cripples students when they need to move onto something whose copyright message isn't written as (c) MCMLXXXIX

    @ grumpy
    Yeah - I hear that!!!!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  12. #12
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    It's unfortunately more widespread than what one would probably like, Salem.

    You can see this same issue in several countries in Europe, certainly Africa, Asia and the Americas. I would go as far as to believe that even in most well developed countries, some schools break the rules. I know they do in Australia where I lived many years.

    In fact, what is somewhat entertaining to watch is that it is exactly third-world countries and emerging countries, which hadn't so far regulated IT teaching, that come up with the most advanced and well thought of regulations.

    After all they don't have the huge educational system and its more than usual resistance to change tied to their backs dragging them to the past.

    However, one thing I must say, mostly based on my opinion... As far as high school goes, it is irrelevant if I learn with Turbo C or the latest MinGW release. It is even irrelevant if I'm taught C or C++.

    I know this last statement is probably taking it too far. However, in my time I was taugh Pascal only in high school and that didn't stop my generation to provide the country with some of the most prolific C++ computer programers since. (I, unfortunately, took another turn).

    At high school level, I believe it is the thought process that matters most. Familiarity with general programming language constructs, program design and programming seeing as an unit with one language and one compiler of choice to enable the pratical side of things.

    I believe C++ greatest strenght as a teaching tool on how to program is the fact it is a multiparadigm programming language (Stroustrup FAQ). The libraries... well, high school objective is not to teach programming in C++. It is to teach programming. If the high school educational system is crystalized on this matter or too expensive to change, I can understand this without necessarily seeing in it the root of an evil.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  13. #13
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    At high school level, I believe it is the thought process that matters most. Familiarity with general programming language constructs, program design and programming seeing as an unit with one language and one compiler of choice to enable the pratical side of things.
    I can see where you are coming from, and that is also one of the reasons why I think any attempts for me to try and get an upgrade of compiler in my old school will be ignored.

    I believe C++ greatest strenght as a teaching tool on how to program is the fact it is a multiparadigm programming language (Stroustrup FAQ). The libraries... well, high school objective is not to teach programming in C++. It is to teach programming.
    I think that one has to start somewhere. You cannot teach programming without teaching some kind of programming language, so you might as well teach that language well, with modern constructs and concepts. This way, students can get their hands on updated references and other resources and more easily extend their knowledge beyond the basics taught, should they want to.

    For example, take Accelerated C++, by Koenig and Moo. The book was written to teach C++ programming. Unlike most introductory texts on C++ in educational institutions, it starts off by using constructs from the C++ standard library, one of which is notably std::vector.

    However, it inevitably ends up teaching programming in the sense that one learns certain programming concepts and ideas. The use of std::vector introduces the concept of a sequential container with random access, yet frees the student of having to understand memory management early on. Along the way one learns problem solving skills, program organisation, intelligent selection of data structures, etc.

    Eventually, as the student gains practice with solving problems and applying knowledge is is not necessarily C++ specific, the nitty gritty of the abstractions provided by the standard library are revealed, step by step. I think this is much better than trying to teach C++ by starting with the C route, since the student learns standard C++, yet the abstractions help the student to more readily learn programming in general.
    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

  14. #14
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by laserlight
    I think that one has to start somewhere. You cannot teach programming without teaching some kind of programming language, so you might as well teach that language well, with modern constructs and concepts.
    Oh, absolutely! However, sometimes (and I guess this is especially true for the governments) inertia, budget constraints, aging teachers, and, truth be told, bad decisions, get in the way of what is right.

    Students are remarkably more prone to change and more maleable (and bright) than their teachers, thank goodness. That is probably why it doesn't worry me much if my daughter will learn with <iostream.h> or <iostream> in a couple of years. It does worry me though that, with the former, her teacher will be limiting her study reference material.

    ... and Accelerated C++... awsome book. That with Lippman and others' C++ Primer, and Stroustrup's C++ have been my companions. Eagerly waiting for Musser's STL Tutorial and Reference Guide. Then just need some serious book on classes design and implementation.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  15. #15
    Registered User
    Join Date
    Jun 2006
    Posts
    8
    I could beg the school to change the course a bit, but it'll be really tough to contact the CBSE and convince them to change their course. The CBSE simply never listens. Any Indian teenager can tell you that. But I'll try anyways.

    BTW, during higher education, they do teach the standards compliant C++. It'll be impossible for people to get jobs without <iostream>!

    What people have been saying so far (that the objective of C++ at school level is to teach programming logic and problem solving skill), in my opinion, is perfectly true. You can't do anything useful with what they teach you. They have a chapter on SQL in class 12th, but it doesn't tell how to use SQL with C++ (and our teachers call SQL "sequel". Sequel to what?). What they're teaching now I knew when I was in class 8th (I'm now in 11th).

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 Yumin in forum C++ Programming
    Replies: 30
    Last Post: 01-31-2006, 02:00 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