Namespaces is used to group together all the related classes.
To use namespace, using keyword or scope resolution operator can be used.
namespace emp
{
class Manager
{
public:
static void showDetail()
{
...
...
}
};
}
{
class Manager
{
public:
static void showDetail()
{
...
...
}
};
}
To use
emp::Manage::showDetail();
or
using namespace emp;
Manager::showDetail();
Manager::showDetail();
What are the guidelines of using namespaces?
To name a namespace, utilize the company name followed by the department and optionally followed by the features and technology used.
For example:
MyCompany.Media.Design
The following are some guidelines to name namespaces.
- The prefix of company name avoids the possibility of two or more namespaces with same name.
- Use a stable, noticeable department or technology name followed by the company name at the hierarchical name of second level.
- Use organizational hierarchies as the basis for name space hierarchies.
- Separate the logical components with periods (.).
- Avoid giving same name for classes and name spaces.

0 Comments:
Post a Comment