Menghui Xie 2021-09-23 00:24:28 +08:00
parent 7b7c850358
commit d147baea68
3 changed files with 33 additions and 0 deletions

View File

@ -127,6 +127,17 @@ const int* function6(); // returns a pointer variable to a constant, use: co
int* const function7(); // returns a constant pointer to a variable, use: int * const p = function7 ();
```
#### #define and const constants
#define|const constants
---|---
Macro definitions, equivalent to character substitution|constant declarations
preprocessor processing|compiler processing
without type safety checking|with type safety checking
no memory allocation|memory allocation required
stored in code segment|stored in data segment
Can be canceled by `#undef`|Not cancelable
### static
#### Function

View File

@ -115,6 +115,17 @@ const int* function6(); // 返回一个指向常量的指针变量,使用
int* const function7(); // 返回一个指向变量的常指针使用int* const p = function7();
```
#### 宏定义 #define 和 const 常量
宏定义 #define|const 常量
---|---
宏定义,相当于字符替换|常量声明
预处理器处理|编译器处理
无类型安全检查|有类型安全检查
不分配内存|要分配内存
存储在代码段|存储在数据段
可通过 `#undef` 取消|不可取消
### static
#### 作用

View File

@ -120,6 +120,17 @@ const int* function6(); // returns a pointer variable to a constant, use: co
int* const function7(); // returns a constant pointer to a variable, use: int * const p = function7 ();
```
#### #define and const constants
#define|const constants
---|---
Macro definitions, equivalent to character substitution|constant declarations
preprocessor processing|compiler processing
without type safety checking|with type safety checking
no memory allocation|memory allocation required
stored in code segment|stored in data segment
Can be canceled by `#undef`|Not cancelable
### static
#### Function