Commit 3ff4eb36 authored by 24OI-bot's avatar 24OI-bot
Browse files

style: format markdown files with remark-lint

parent 16b0d35b
Loading
Loading
Loading
Loading
+23 −33
Original line number Diff line number Diff line
@@ -9,14 +9,10 @@ C++ 的 **命名空间** 机制可以用来解决复杂项目中名字冲突的
下面的代码声明了一个名字叫 `A` 的命名空间:

```cpp
namespace A
{
namespace A {
int cnt;
 void f(int x)
 {
  cnt=x;
 }
}
void f(int x) { cnt = x; }
}  // namespace A
```

声明之后,在这个命名空间外部,你可以通过 `A::f(x)` 来访问命名空间 `A` 内部的 `f` 函数。
@@ -24,20 +20,14 @@ namespace A
命名空间的声明是可以嵌套的,因此下面这段代码也是允许的:

```cpp
namespace A
{
 namespace B
 {
  void f()
  {
   ...
  }
 }
 void f()
 {
namespace A {
namespace B {
void f() { ... }
}  // namespace B
void f() {
  B::f();  // g 函数位于命名空间 A 内,所以可以省略前面的 A::
}
}
}  // namespace A

void f()  //这里定义的是全局命名空间的 f 函数,与 A::f 和 A::B::f 都不会产生冲突
{
+1 −1

File changed.

Contains only whitespace changes.