Chinaunix首页 | 论坛 | 博客
  • 博客访问: 360725
  • 博文数量: 100
  • 博客积分: 2500
  • 博客等级: 大尉
  • 技术积分: 1209
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-15 21:24
文章分类

全部博文(100)

文章存档

2011年(100)

分类: C/C++

2011-04-19 13:25:47

Format:
  1. namespace identifier
  2. {
  3. entities
  4. }
The keyword using is used to introduce a name from a namespace into the current declarative region.
Example:
  1. #include <iostream>
  2. using namespace std;

  3. namespace first
  4. {
  5.         int x = 5;
  6.         int y = 10;
  7. }

  8. namespace second
  9. {
  10.         double x = 3.1416;
  11.         double y = 2.7183;
  12. }

  13. int
  14. main(void)
  15. {
  16.         using first::x;
  17.         using second::y;
  18.         cout << x << endl;
  19.         cout << y << endl;
  20.         cout << first::y << endl;
  21.         cout << second::x << endl;

  22.         return (0);
  23. }

We can declare alternate names for existing namespaces:
  1. namespace new_name = current_name;












阅读(891) | 评论(0) | 转发(0) |
0

上一篇:模板

下一篇:异常

给主人留下些什么吧!~~