using namespace std; // using compiler directives, it will be a one-time to all entities std space bringing all
// Requirements: Familiar space entity
// now, not recommended
namespace wd
{
void display()
{
cout << "wd::display() " << endl;
}
}//end of namespace wd
namespace tls
{
void display()
{
cout << "tls::display() " << endl;
}
}//end of namespace tls
main int (void)
{
WD :: Run the display (); // :: scope qualifier , which is the full form
tls :: display ();
return 0;
}
using std :: cout; // using declaration mechanism, streamline operations, will not bring in all the entities
// namespace can appear multiple times in a file
// corresponds to a black hole
namespace WD
{
int Number = 10;
void Show (); // declare
} // end of namespace wd
namespace tls
{
void display()
{
cout << "tls::display() " << endl;
wd::show();
}
}//end of namespace tls
namespace wd
{
void display()
{
cout << "wd::display() " << endl;
tls::display();
}
void show()//实现
{
cout << "wd::show()" << endl;
}
}//end of namespace wd
int number = 10;
namespace wd
{
int number = 100;
namespace lwh
{
void display()
{
cout << "wd::lwh::display()" << endl;
}
}//end of namespace lwh
}//end of namespace wd
namespace tls
{
int number = 1000;
void display (int number) // number parameter will block the other number
{
COUT << "number =" << endl << number;
COUT << "WD number :: =" << endl << number WD :: ;
cout << "Number The TLS :: =" << endl << Number The TLS ::;
cout << "global variable number =" << :: number << endl ; // anonymous namespace
}
}//end of namespace tls