[go: nahoru, domu]

Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagi-ovo committed Oct 18, 2023
1 parent 8bb1271 commit 86e4579
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/1-50/05 How C++ Works.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
每个 cpp 程序都有一个类似`main`函数的东西,被称作*entry point*
后面了解到这个必须的原因在于.exe 可执行文件必须需要一个入口,可在设置中自定义入口点(不一定必须是 main function)

只有主函数可以不返回任何值,默认返回 0 ^d4cfc1
只有主函数可以不返回任何值,默认返回 0

*preprocessor statement*被评估后,我们的文件会被编译,这个阶段,编译器把我们的 cpp 代码转化为实际的机器码

Expand Down Expand Up @@ -80,6 +80,6 @@ _==注意==_:error list 不好用,工作原理是*parse*(解析)output 窗口
| void Log(x) | void Log(x){ code...} |

文件被编译后,linker 会去找函数的定义,然后跟 main 中调用的联系起来。如果找不到会得到 linker error
只有主函数可以不返回任何值,默认返回 0 ^2224fe
只有主函数可以不返回任何值,默认返回 0

*preprocessor statement*被评估后,我们的文件会被编译,这个阶段,编译器把我们的 cpp 代码转化为实际的机器码
2 changes: 2 additions & 0 deletions docs/1-50/31 Arrays in C++.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,15 @@ std::cout << count << std::endl; // 5:元素的数量
```

如果做`sizeof(example)`的话,会返回整形指针的大小(4),故你只能在栈分配的数组上用这个技巧

![](./storage%20bag/Pasted%20image%2020230704234722.png)

改回`int example[5];`也能工作,但是你真的不能相信这个方法

#### 一个重点

当你在栈中为数组申请内存时,它必须\*是一个编译时就需要知道的常量(以后会有别的方法解决)

![](./storage%20bag/Pasted%20image%2020230704234937.png)

```cpp
Expand Down

0 comments on commit 86e4579

Please sign in to comment.