0
What's the meaning of the namespace
3 Respuestas
+ 2
namespaces helps to shorten codes. For example:
instead of this:
stdout::cout << "hello world!" << endl
by using namespaces like
using namespace std;
the code becomes simpler like this:
cout << "hello world!" << endl
+ 2
you can do
namespace a {
void print(){
cout << "a";
}
}
namespace b {
void print(){
cout << "b";
}
}
and now you can call
a::print (); // a
b::print (); // b
or
using namespace a;
...
print(); //a
[edit]
the std namespace contains all C++ standard functions, classes, etc (only C++ headers like iostream, string, etc.. C headers like stdio.h (cstdio) or time.h (ctime) don't use namespace because C doesn't support namespace)