Skip to content

Commit

Permalink
Merge pull request huihut#82 from Charmve/patch-1
Browse files Browse the repository at this point in the history
新增 #define与const的区别
  • Loading branch information
huihut authored Sep 22, 2021
2 parents 8250e43 + 1115ef4 commit 7b7c850
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ const int* function6(); // 返回一个指向常量的指针变量,使用
int* const function7(); // 返回一个指向变量的常指针,使用:int* const p = function7();
```
#### 宏定义 #define 和 const 常量
宏定义 #define|const 常量
---|---
宏定义,相当于字符替换|常量声明
预处理器处理|编译器处理
无类型安全检查|有类型安全检查
不分配内存|要分配内存
存储在代码段|存储在数据段
可通过 `#undef` 取消|不可取消
### static
#### 作用
Expand Down

0 comments on commit 7b7c850

Please sign in to comment.