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();
}
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();
}
相关文章推荐
- C++学习笔记--new和namespace
- C++学习笔记1-namespace是什么东西?
- C++ namespace笔记
- C++学习笔记之---namespace的使用
- c++ primer plus阅读笔记10---定位new using namespace
- <<C++程序设计与原理>> 笔记
- OpenSceneGraph 笔记--C++/CLI写托管Scene类
- C++学习笔记(二)
- C++学习笔记 3rd —— 数组
- C++学习笔记7
- C++学习笔记:3.3.5 继承中的同名成员变量和函数
- 《数据结构与算法分析--C++描述》(第三版)学习笔记系列一:BST的实现
- C++学习笔记——STL
- C++学习笔记(二十七)cin.getline()、getline()的用法
- Visaul C++ 2010 入门经典 学习笔记(1)
- c++笔记:(3)C++ 类 & 对象
- c/c++ 练习笔记
- c++学习笔记(运算符重载)
- c/c++ 复习笔记 第五天
- c++第一天笔记(上)