Thread: Question about the std namespace (documentation, not usage)

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    88

    Question about the std namespace (documentation, not usage)

    Hi all,

    I've recently moved to programming in C++ and I just had a quick question about the std namespace. I'm okay with the syntax, and I've read up on why namespaces were instituted, I'm just having trouble finding some info online:

    Recently, when using the <vector> library, I had to do some fiddling about until I realized I need to preface declarations with std:: as with functions like std::cin and std::cout. I've avoided using the line "using namespace std" as I've read it can lead to confusion in more complicated programming.

    Can anyone point me to a resource which has a comprehensive list of which libraries fall under the std namespace?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Ocifer View Post
    Hi all,

    I've recently moved to programming in C++ and I just had a quick question about the std namespace. I'm okay with the syntax, and I've read up on why namespaces were instituted, I'm just having trouble finding some info online:

    Recently, when using the <vector> library, I had to do some fiddling about until I realized I need to preface declarations with std:: as with functions like std::cin and std::cout. I've avoided using the line "using namespace std" as I've read it can lead to confusion in more complicated programming.

    Can anyone point me to a resource which has a comprehensive list of which libraries fall under the std namespace?
    All of them, or at least all of them that are "built-in" C++. If you go somewhere like cplusplus.com, you'll see what's standard and what's not.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    88
    Thanks. For anyone who has a similar question, I found what I was looking for at:

    Reference - C++ Reference

    If it helps clear this up for anyone else, my confusion was that I thought the preface " std:: " was only used for standard iostream functions like cin or cout or cin.get, etc... This is not the case, and rather at the above link there are a number of different commonly-used libraries which fall under the "std" namespace, of which <vector> is one.
    Last edited by Ocifer; 05-27-2011 at 12:57 PM.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Everything in the C++ standard library lies in the std namespace. So when you include a standard header (eg, vector, map, algorithm), all functions and classes will be in std!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Namespace question....
    By CommonTater in forum C++ Programming
    Replies: 10
    Last Post: 01-16-2011, 03:21 PM
  2. namespace question
    By Dave++ in forum C++ Programming
    Replies: 6
    Last Post: 06-04-2007, 05:47 PM
  3. Namespace question
    By xmltorrent in forum C++ Programming
    Replies: 1
    Last Post: 08-13-2006, 01:30 PM
  4. namespace question
    By black in forum C++ Programming
    Replies: 4
    Last Post: 06-03-2002, 07:11 PM
  5. namespace question
    By Sebastiani in forum C++ Programming
    Replies: 2
    Last Post: 04-20-2002, 01:16 PM