Saturday, April 13, 2013

why we use "using namespace std;" in C++



why we use "using namespace std;" in C++  ?

Without using namespace std; when you write for example cout <<; you'd have to put std::cout <<;

Here's a small example for you:
*without using namespace std;

#include <iostream>

int main()
{
    std::cout << "Hello World";
    system("pause");
    return 0;
    
}

*with using namespace std;

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello World";
    system("pause");
    return 0;
    
}


They both do the exact same thing.

                                     (( amul patel ))

1 comment:

  1. I think it does't means for turbo c++!!!!its useing for compiler like visual c++!!

    ReplyDelete