Skip to content

Commit

Permalink
@DiDongDongDi 提供】修改范围解析运算符例子
Browse files Browse the repository at this point in the history
  • Loading branch information
huihut committed Feb 28, 2020
1 parent 09562fd commit 8cf0448
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,22 +582,28 @@ cout << x << endl;
:: 使用

```cpp
int count = 0; // 全局(::)的 count
int count = 11; // 全局(::)的 count

class A {
public:
static int count; // 类 A 的 count(A::count)
static int count; // 类 A 的 count(A::count)
};
int A::count = 21;

void fun()
{
int count = 31; // 初始化局部的 count 为 31
count = 32; // 设置局部的 count 的值为 32
}

int main() {
::count = 1; // 设置全局的 count 的值为 1
::count = 12; // 测试 1:设置全局的 count 的值为 12

A::count = 2; // 设置类 A 的 count 为 2
A::count = 22; // 测试 2:设置类 A 的 count 为 22

int count = 0; // 局部的 count
count = 3; // 设置局部的 count 的值为 3
fun(); // 测试 3

return 0;
return 0;
}
```
Expand Down
20 changes: 13 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,22 +544,28 @@ cout << x << endl;
:: 使用

```cpp
int count = 0; // 全局(::)的 count
int count = 11; // 全局(::)的 count

class A {
public:
static int count; // 类 A 的 count(A::count)
static int count; // 类 A 的 count(A::count)
};
int A::count = 21;

void fun()
{
int count = 31; // 初始化局部的 count 为 31
count = 32; // 设置局部的 count 的值为 32
}

int main() {
::count = 1; // 设置全局的 count 的值为 1
::count = 12; // 测试 1:设置全局的 count 的值为 12

A::count = 2; // 设置类 A 的 count 为 2
A::count = 22; // 测试 2:设置类 A 的 count 为 22

int count = 0; // 局部的 count
count = 3; // 设置局部的 count 的值为 3
fun(); // 测试 3

return 0;
return 0;
}
```
Expand Down

0 comments on commit 8cf0448

Please sign in to comment.