A using-declaration brings one name into a scope. This name can be used as if it was declared locally.
For example,
using std::vector;
Note that the keyword 'namespace' is not used.
A using-directive brings all the names of the namespace into a scope.
For example,
using namespace std;
You can also have a namespace alias, which can be used make a namespace name shorter or clearer.
For example,
namespace WHAT_YOU_SEE_IS_WHAT_YOU_GET {
void widget();
}
namespace WYSIWYG = WHAT_YOU_SEE_IS_WHAT_YOU_GET;
Reference: The C++ Programming Language
No comments:
Post a Comment