what does "using namespace std" mean?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sharadbags
    New Member
    • Dec 2006
    • 14

    what does "using namespace std" mean?

    In many programs
    using VC++ compilers
    i have seen this thing
  • Artem
    New Member
    • Apr 2007
    • 3

    #2
    Originally posted by sharadbags
    In many programs
    using VC++ compilers
    i have seen this thing
    There are a lot of libraries in c++. In some there may be functions with the same name. To distinguish them namespaces are used.
    for example, you create a class library:
    Code:
    namespace myn
    {
     class cin
     {
      puclic:
        int c(void);
     }
    }
    Now you can call your function and be sure that compiler understand that it is your class cin and not a standard input stream:
    Code:
    #include <iostream>
    ...
    int kk = myn::cin.c(); // your function
    char c = std:: cin.getc(); // standard cin has 'std' namespace
    ...
    You can use namespaces as written in prev. example, or you add line
    Code:
    using namespace std;
    and write everywhere without 'std::'. Like here:
    Code:
    #include <iostream>
    using namespace std;
    ...
    char c = cin.getc();
    cin >> c;
    for more info, look msdn ;-)

    Comment

    Working...