This commit is contained in:
Light-City
2020-03-05 15:46:10 +08:00
parent 3557bd2783
commit 9940049f8f
8 changed files with 16 additions and 2 deletions

Binary file not shown.

View File

@@ -0,0 +1,14 @@
# :: 范围解析运算符那些事
## 关于作者:
个人公众号:
![](../img/wechat.jpg)
- 全局作用域符(::name用于类型名称类、类成员、成员函数、变量等表示作用域为全局命名空间
- 类作用域符class::name用于表示指定类型的作用域范围是具体某个类的
- 命名空间作用域符namespace::name:用于表示指定类型的作用域范围是具体某个命名空间的
具体代码见:[maohao.cpp](maohao.cpp)

View File

@@ -0,0 +1,14 @@
# :: 范围解析运算符那些事
## 关于作者:
个人公众号:
![](../img/wechat.jpg)
- 全局作用域符(::name用于类型名称类、类成员、成员函数、变量等表示作用域为全局命名空间
- 类作用域符class::name用于表示指定类型的作用域范围是具体某个类的
- 命名空间作用域符namespace::name:用于表示指定类型的作用域范围是具体某个命名空间的
具体代码见:[::.cpp](::.cpp)

View File

@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;
int count=0; // 全局(::)的count
class A {
public:
static int count; // 类A的count (A::count)
};
// 静态变量必须在此处定义
int A::count;
int main() {
::count=1; // 设置全局的count为1
A::count=5; // 设置类A的count为2
cout<<A::count<<endl;
// int count=3; // 局部count
// count=4; // 设置局部的count为4
return 0;
}