您的位置:首页 > 编程语言 > C语言/C++

namespace笔记----C++

2017-11-07 22:34 183 查看
  1.namespace有什么用?

namespace,要用来把东西区分开来,假如a与b独立工作,制造出来的类名字有可能会相同,就用namespace来区分

那我a就再用一个名字把这包含起来,b也用一个名字包含起来。

  2.代码示例:

using namespace std;

#include <iostream>
#include <memory>
namespace jj01
{
void test_member_template(){.....}
}

#include <iostream>
#include <list>
namespace jj02
{
template<typename T>
using Lst=list<T,allocator<T>>;
void test_template_template_param(){....}
}测试用例:
int main()
{
jj01::test_member_template();
jj02::test_template_template_param();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: