Classes: Namespaces
Applies To: C++Builder 1 or higher
Category: C++ Language
- A namespace allows the application to be partitioned in multiple sections. Namespaces create local scopes and therefore can provide multiple definitions of the same name. The general form of a namespace is:
-
namespace namespace_name {
}
|
-
- For example:
-
- namespace List {
- int Count;
- }
-
- There are two ways to access variables declared in a namespace. You can provide the namespace followed by the :: operator and then the variable name:
-
- List::Count = 10;
-
- Or by adding the entire namespace to the current scope with the using keyword:
-
- using namespace List;
-
- Count = 10;
C++Builder Developer's Network
Copyright © Yoto Yotov