I just like the simple expression.
The purpose of using namespaces is to localize the names of identifiers to avoid naming conflicts.
NAMESPACE  We can also create our own namespaces in our own programs so that we can localize names that we think might cause conflicts. This is especially important when we are creating classes or libraries of functions.
Namespace Basics
namespace keywords allow us to delimit global namespaces by creating scopes. Essentially, a namespace defines a scope. The basic form of defining the namespace is as follows:
NAMESPACE  name {// declaration }
Anything defined in a namespace is confined to that namespace.
using key Words
If you need to refer to a member of a namespace more than once in a program, it is cumbersome to use the scope resolver to specify the namespace each time, as we have previously said. To solve this problem, people have introducedusingkey word. usingstatements usually have two ways of using them:
using namespace namespace name
USING&NBSP; < Span style= "font-family: ' The song Body '; > namespace name < Span style= "Color:rgb (68,68,68);" >:: member;
Reproduced above http://blog.chinaunix.net/uid-26874138-id-3215266.html
=============================================================================
Files: student.h
#include <iostream>using namespace std;namespace stu { class student { public: student () {}; ~student () {}; int fun () { cout << "Stu" << endl; } };} namespace ter { class student { public: student () {}; &nBsp; int fun () { cout << "Teacher" < < endl; } };}
File name: Namespace.cxx
#include <stdio.h> #include <iostream> #include "student.h" using namespace std;using namespace stu;using namespace Ter;int main (void) {stu::student A; Ter::student b; A.fun (); B.fun (); return 0;} ~
Summary: A name for a space, content randomly repeated complementary interference.
This article is from the "Self-summary" blog, please be sure to keep this source http://2714254.blog.51cto.com/2704254/1683760
C + + namespaces