C++ namespace Create a Namespace
#include <iostream> using namespace std; namespace Work/*from w ww . jav a 2s .c o m*/ { int myVal; class Info { public: string CompanyName; string Position; }; void DoStuff() { cout << "Doing some work!" << endl; } } namespace Play { int myVal; class Info { public: string FullName; string Hobby; }; void DoStuff() { cout << "Having fun!" << endl; } } int main() { // Work stuff Work::myVal = 7; Work::Info MyName; MyName.CompanyName = "java2s.com"; MyName.Position = "Worker"; Work::DoStuff(); // Play stuff Play::myVal = 13; Play::Info PlayInformation; PlayInformation.FullName = "g Jetson"; PlayInformation.Hobby = "this is a test"; Play::DoStuff(); return 0; }