Heres a question

This is a discussion on Heres a question within the C++ Programming forums, part of the General Programming Boards category; If this question seems stupid, than please just ignore it. But, I've been programming in C++ for awhile. I have ...

  1. #1
    C++/Graphics Artist
    Join Date
    Aug 2005
    Location
    USA
    Posts
    10

    Heres a question

    If this question seems stupid, than please just ignore it. But, I've been programming in C++ for awhile. I have seen 2 varities of coding styles, one without namespace, which I use:
    Code:
    cout<<"Hi there!\n";
    and one with:
    Code:
    std::cout<<"Hi there!\n";
    Heres my question, why is std namespace there? Is it really neccessary? I mean its still the same function is it not? I apologize if this question seems right-minded, but I would like to know.
    .//website | .//anime | .//design
    - Project Crimson Blade - Text-based MMORPG. Powered by MySQL and PHP.
    - Web Blog: http://rylem.blogspot.com
    -----------------
    Primary OS: Windows 2000 Professional SP4
    Secondary OS: Ubuntu Linux 5.4 (Will be Fedora Project Core 4)
    Purpose: Multi-purpose programmer, artist, and designer.

  2. #2
    Banned
    Join Date
    Jun 2005
    Posts
    594
    if you are using cout without std:: you are

    Code:
    using namespace std;
    or you are using a depreciated header such as iostream.h

    many prefer to type std:: instead of using namespace std;
    because then you have to remember which namespace it is
    from, typing using namespace std; pretty much just lets
    you do elss typing, and its a matter of opinion which you
    choose to use. unless of course it the depreciated header,
    in which case you should revise your technique.

    also and also
    Last edited by ILoveVectors; 08-12-2005 at 07:30 PM.

  3. #3
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    As ILoveVectors said its a matter of choice, but the namespace std was put on the new hearder file so you can have a function/macro with the same name.
    My Website
    010000110010101100101011
    Add Color To Your Code!

  4. #4
    C++/Graphics Artist
    Join Date
    Aug 2005
    Location
    USA
    Posts
    10
    Oh, I see. So its just a matter of choice. I think I'll start putting "std::" now, just to develope a good habit.
    .//website | .//anime | .//design
    - Project Crimson Blade - Text-based MMORPG. Powered by MySQL and PHP.
    - Web Blog: http://rylem.blogspot.com
    -----------------
    Primary OS: Windows 2000 Professional SP4
    Secondary OS: Ubuntu Linux 5.4 (Will be Fedora Project Core 4)
    Purpose: Multi-purpose programmer, artist, and designer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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