Results 1 to 9 of 9

Thread: Header with '.'?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    Texas
    Posts
    140

    Cool Header with '.'?

    Why doesn't everyone start using (unless you have an older compiler) the:

    #include <iostream> //notice no .h

    using namespace std;

    ?

    Was just wondering if their is a reason between the two.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    It's a filename, it doesn't need to be .h it could be .banana if you want
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    That would be cool in a weird kind of way. If I ever write a language, header files will be .banana

    The reason most people don't use the STL versions is because:

    a) it's a new(er) style of syntax that old tutorials/books don't mention

    b) anyone using M$ VC++ will see the .h included in any help file examples, since that will use M$'s header files (slightly different from the ANSI ones).
    Harry.

    "From one thing, know ten thousand things."

  4. #4
    Zaei
    Guest
    Yeah, Harry, and source files could be .monkey =P.

    Z.

  5. #5
    Sc0rp
    Guest
    I just bought a C++ book, and it states that using the ANSI standard versions (no .h) and namespace std has very strong debugging and OOP differences. The ANSI version is actually the OOP version.

  6. #6
    Destined Soul
    Guest
    I was taught to use the <iostream.h> syntax in University... (which was 4 years ago.)

    What's the difference with using just <iostream>? Is there any specific ways you have to call functions using this? Benefits? Downsides? And what does std do?

    Destined
    (A guy who switched his majors from Computer Science to Physics, 4 years ago... )

  7. #7
    Sc0rp
    Guest
    For example, there is a major difference between <string.h> and <string>.
    The first one is the C include, which contains functions for string (char array) manipulation.
    The second one is actually a C++ string class + the functions from the C include file.

  8. #8
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    The old .h style header includes got deprecated a while back, but AFAIK it was standard to use .h style includes in C++ up until then. I have no idea when the governing bodies of C++ decided to drop the .h, but it could have been less than 4 years ago I guess.

    I was taught to use .h too, but I was being taught C, not C++.

    std is the standard namespace. When you include STL headers, their contents go into the std namespace (I think that goes for all STL headers, but I'm not sure). Namespaces are very useful to prevent naming conflicts by placing things in their own custom scopes. The using directive can place you in a different namespace to the default namespace (the global namespace), which can ease your typing by preventing you from having to fully qualify every variable and function from that namespace you use with the scope.

    So, without the using directive you would type:

    std::cout

    but with it you could write just:

    cout

    Anyway it's good practice to use the non-deprecated versions of things, so use the new style.
    Harry.

    "From one thing, know ten thousand things."

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    And as a qualification, you should never use using namespace whatever; in a header file, because that can really mess things up as it applies it to every source file it's included in. The using directive only otherwise applies to the current source file.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width