C++面向对象技术(8):命名空间及this的概念
发布时间
阅读量:
阅读量
C++面向对象(八):命名空间、this的原理
文章结构概述
-
- C++面向对象(八):命名空间、this的原理
-
- 命名空间
-
- 命名空间的嵌套
-
命名空间的合并
- this的原理
-
- C++面向对象(八):命名空间、this的原理
命名空间
命名空间的应用有助于规避命名过程中可能出现的冲突问题
int g_age;
void func() {};
namespace NB {
// 全局变量
int g_age;
void func() {};
class Person {
int m_age;
public:
Person() {
cout << "NB这里的" << endl;
}
};
}
class Person {
private:
int m_age;
int m_id;
public:
Person() {
cout << "外面的" << endl;
};
int main() {
// 默认使用外面的
Person person1;
全部评论 (0)
还没有任何评论哟~
