C++ 命名空间 实战(一)
C++ 实战 空间 命名
2023-09-14 09:09:30 时间
#include <iostream>
using namespace std;
// 第一个命名空间
namespace first_space {
void func() {
cout << "Inside first_space" << endl;
}
}
// 第二个命名空间
namespace second_space {
void func() {
cout << "Inside second_space" << endl;
}
}
int main()
{
// 调用第一个命名空间中的函数
first_space::func();
// 调用第二个命名空间中的函数
second_space::func();
return 0;
}
Inside first_space
Inside second_space
#include <iostream>
using namespace std;
// 第一个命名空间
namespace first_space {
void func() {
cout << "Inside first_space" << endl;
}
}
// 第二个命名空间
namespace second_space {
void func() {
cout << "Inside second_space" << endl;
}
}
using namespace first_space;
int main()
{
// 调用第一个命名空间中的函数
func();
return 0;
}
Inside first_space
#include <iostream>
using std::cout;
int main ()
{
cout << "std::endl is used with std!" << std::endl;
return 0;
}
std::endl is used with std!
相关文章
- C++项目职工管理系统-项目分析
- C++学习——c++逗号操作符说明(附加全部运算符优先级)
- python和c++哪个好_run pycharm community edition
- C++运算符重载和函数重载
- 深入理解C++11_c++ string char
- C++构造函数的作用_c++什么是构造函数
- C++基本概念_c语言 c++区别
- C++字符串加密_c++字符串连接函数
- C++ 调用 Halcon 时大尺寸操作无效问题的解决方案
- c++的链表-C++实现简单链表
- C/C++ 获取操作系统版本
- C/C++ 实现获取Linux系统参数
- C++ 中文周刊 第103期
- 开心档之C++ 循环
- C++哈希应用——布隆过滤器
- C++字符串输入输出操作详解
- C++ STL流缓冲区迭代器(streambuf_iterator)
- 浅析C#与C++相关概念的比较
- C++空类详解
- c/c++中变量的声明和定义深入解析
- C++中Semaphore内核对象用法实例
- C++中关于[]静态数组和new分配的动态数组的区别分析