|
-
February 5th, 2004, 08:41 PM
#4
Let me try to explain it slightly differently. The C++ standard introduce namespace keyword which partition the global namespace for avoiding name conflict. This is especially true when we need to use different libraries from different vendors. There is no way these vendors can avoid using the same name. Similarly, all standard library stuff are being placed into std namespace for the same reason.
Suppose we want to use only std::cout, there isn't really a need to import everything from std::namespace. If we are "using namespace std", it imports more than we need and it only pollute the global namespace. As a result, C++ also provide 2 other methods for accessing any object within any namespace.
1. using std::cout
This method only import cout from std namespace and avoid polluting the global namespace.
2. std::cout
Fully specified with the resolution scope. This is most in header files.
Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|