0

What's the meaning of the namespace

29th Jul 2017, 11:37 PM
Abdul Haq
3 ответов
+ 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
30th Jul 2017, 12:14 AM
Benneth Yankey
Benneth Yankey - avatar
+ 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)
30th Jul 2017, 12:23 AM
Andrés04_ve
Andrés04_ve - avatar