wat is namespace std

closed account (i2v7M4Gy)
"all the elements of the standard C++ library are declared within wat is called a namespace,the namespace with the name std" Please explain this.Wat the namespace std include?How many namespaces C++ has?
In C++ if you didn't include using namespace std; in your file you would have to constantly have to add the std prefix.

i.e

1
2
3
using namespace std;

cout << "Hello" << endl;


Without using the namespace declaration
 
std::cout << "Hello" << std::endl;


A namespace encloses a file. A prefix then has to be used on every element of that file. Namespaces help avoid naming conflicts.
Last edited on
Topic archived. No new replies allowed.