Standard namespace?

This is a discussion on Standard namespace? within the C++ Programming forums, part of the General Programming Boards category; Please forgive me if I have not formulated the question correctly, or placed it in the wrong forum. Does anyone ...

  1. #1
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589

    Standard namespace?

    Please forgive me if I have not formulated the question correctly, or placed it in the wrong forum.

    Does anyone know of a website that summarizes the rules behind writing code w/o a header?

    I have seen mulititudes of code written with the following, and I want to start using this technique.
    Code:
    std::cout
    std::cin
    I'm assuming, and correct me if I'm wrong that this says.
    With using the standard name space, execute cout.
    Is there other formats of this syntax, and possibley a list of ways to use it?

    I'm assuming again that the primary reason for writing in this way is to prevent syntax conflicts. Is this correct?

    Thank you for any assistance this provides.
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    writing code w/o a header
    You'll notice that you still have to include iostream to get cin and cout.

    I'm assuming again that the primary reason for writing in this way is to prevent syntax conflicts. Is this correct?
    It's more to prevent naming conflicts. Implementing namespaces allows you to make your own namespaces and use them without having to worry about naming something that's already defined in the std namespace.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    I'm assuming, and correct me if I'm wrong that this says.
    With using the standard name space, execute cout.
    What it really says is: use the stream named std::cout. Functions in the standard library have first and last names just like people.

    Search google for 'c++ namespaces' if you want to learn more.

  4. #4
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bug in iterator comparison in C++ standard?
    By steev in forum C++ Programming
    Replies: 14
    Last Post: 07-12-2008, 12:02 AM
  2. Replies: 8
    Last Post: 03-08-2008, 07:50 PM
  3. Standard C++ API
    By sparks in forum C++ Programming
    Replies: 9
    Last Post: 08-26-2005, 05:35 PM
  4. need ; before using namespace std
    By wwfarch in forum C++ Programming
    Replies: 7
    Last Post: 05-11-2004, 10:42 PM
  5. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM

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