Skip to content

Commit 765993c

Browse files
committed
Started Chapter 7
1 parent 585aaf0 commit 765993c

File tree

13 files changed

+95
-66
lines changed

13 files changed

+95
-66
lines changed

Structure.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -466,23 +466,21 @@
466466

467467
尝试将类和函数声明在头文件,编译在`definition.cpp`文件,并用`main.cpp`调用函数和定义对象。
468468

469-
### 数据的生存期
469+
### 作用域与变量生存期
470470

471-
简单介绍下数据的生存期:自动生存期、静态生存期、线程生存期及动态生存期。
472-
473-
它们如何决定不同文件和不同域中的同名数据是否有连接。
471+
#### 作用域
474472

475-
### 作用域与命名空间
473+
解释作用域的概念。
476474

477-
#### 变量类型
475+
#### 变量的生存期
478476

479-
通过几个实验让读者了解外部变量、内部变量、静态变量、静态成员等概念
477+
简单介绍下数据的生存期:自动生存期、静态生存期、线程生存期及动态生存期
480478

481-
#### 作用域
479+
#### 变量的链接方式
482480

483-
解释作用域的概念。阐述它和变量生存期的关系
481+
分为外部链接、内部链接和无链接
484482

485-
#### 命名空间
483+
### 命名空间
486484

487485
如何定义命名空间,怎样使用命名空间。
488486

@@ -571,6 +569,8 @@
571569

572570
#### `const`限定的成员函数
573571

572+
#### `mutable`
573+
574574
### 对象数组、对象指针
575575

576576
#### `string`对象数组

generalized_part.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ \part*{泛讲篇}
55
\import{generalized_parts/}{03_control_flow.tex}
66
\import{generalized_parts/}{04_introduction_to_functions.tex}
77
\import{generalized_parts/}{05_compound_types_and_their_use.tex}
8-
\import{generalized_parts/}{06_custom_types_and_their_use.tex}
8+
\import{generalized_parts/}{06_custom_types_and_their_use.tex}
9+
\import{generalized_parts/}{07_projecting.tex}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
\chapter{代码工程}
2+
当读者已经读到这里的时候,以你的知识,其实已经足够实现很多功能了。将来我们的代码会写得越来越长,花样和技巧也会越来越多,功能的多样性和复杂程度也会逐渐攀升。\par
3+
在开始下一步的内容之前,我深感有必要向读者传授一些基本的工程知识,这样我们才能够更加清晰、简洁、有效地管理我们的代码,提高生产力,并且不致在许多恼人问题上浪费时间。\par
4+
在本章之后,我也会逐步调整示例代码的风格,从新手友好型的 \lstinline@using namespace std@ 逐渐转向通篇 \lstinline@std::@ 的严谨性风格上去。读者也应当学会适应不同风格的代码,并最好形成自己最习惯的一套风格来。\par
5+
希望读者能够在学完本章之后掌握一些代码工程的相关知识,这对我们后续的编程大有裨益。\par
6+
\import{07_projecting/}{01_separate_compilation.tex}
7+
\import{07_projecting/}{02_scope_and_storage_duration.tex}
8+
\import{07_projecting/}{03_namespace.tex}
9+
\import{07_projecting/}{04_coding_style.tex}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\section{跨文件编译}

generalized_parts/07_projecting/02_scope_and_storage_duration.tex

Whitespace-only changes.

generalized_parts/07_projecting/03_namespace.tex

Whitespace-only changes.

generalized_parts/07_projecting/04_coding_style.tex

Whitespace-only changes.

main.aux

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,23 @@
147147
\@writefile{lof}{\contentsline {figure}{\numberline {6.10}{\ignorespaces 赋值过程中,活跃成员的变化}}{143}{figure.6.10}\protected@file@percent }
148148
\@writefile{toc}{\contentsline {section}{\numberline {6.5}类初步}{144}{section.6.5}\protected@file@percent }
149149
\@writefile{lof}{\contentsline {figure}{\numberline {6.11}{\ignorespaces \lstinline @public@ 成员提供对外界的接口,而 \lstinline @private@ 成员隐藏了底层的细节}}{145}{figure.6.11}\protected@file@percent }
150+
\@writefile{toc}{\contentsline {chapter}{\numberline {第七章\hspace {.3em}}代码工程}{149}{chapter.7}\protected@file@percent }
151+
\@writefile{lof}{\addvspace {10.0pt}}
152+
\@writefile{lot}{\addvspace {10.0pt}}
153+
\@writefile{toc}{\contentsline {section}{\numberline {7.1}跨文件编译}{149}{section.7.1}\protected@file@percent }
150154
\gdef \LT@ii {\LT@entry
151155
{1}{42.00002pt}\LT@entry
152156
{1}{136.19997pt}\LT@entry
153157
{1}{117.00002pt}\LT@entry
154158
{1}{52.00002pt}\LT@entry
155159
{1}{82.00002pt}}
156-
\@writefile{toc}{\contentsline {part}{精讲篇}{151}{part*.113}\protected@file@percent }
157-
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 A\hspace {.3em}}C++运算符基本属性}{151}{appendix.A}\protected@file@percent }
160+
\@writefile{toc}{\contentsline {part}{精讲篇}{153}{part*.113}\protected@file@percent }
161+
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 A\hspace {.3em}}C++运算符基本属性}{153}{appendix.A}\protected@file@percent }
158162
\@writefile{lof}{\addvspace {10.0pt}}
159163
\@writefile{lot}{\addvspace {10.0pt}}
160-
\newlabel{ch:appendix_A}{{A}{151}{C++运算符基本属性}{appendix.A}{}}
161-
\@writefile{lot}{\contentsline {table}{\numberline {A.1}{截至C++17的所有运算符}}{151}{table.A.1}\protected@file@percent }
162-
\newlabel{tab:A-1}{{A.1}{151}{截至C++17的所有运算符}{table.A.1}{}}
164+
\newlabel{ch:appendix_A}{{A}{153}{C++运算符基本属性}{appendix.A}{}}
165+
\@writefile{lot}{\contentsline {table}{\numberline {A.1}{截至C++17的所有运算符}}{153}{table.A.1}\protected@file@percent }
166+
\newlabel{tab:A-1}{{A.1}{153}{截至C++17的所有运算符}{table.A.1}{}}
163167
\gdef \LT@iii {\LT@entry
164168
{1}{33.67001pt}\LT@entry
165169
{1}{33.81001pt}\LT@entry
@@ -171,11 +175,11 @@
171175
{1}{26.72002pt}\LT@entry
172176
{1}{27.283pt}\LT@entry
173177
{1}{86.44002pt}}
174-
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 B\hspace {.3em}}ASCII码表(0到127)}{153}{appendix.B}\protected@file@percent }
178+
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 B\hspace {.3em}}ASCII码表(0到127)}{155}{appendix.B}\protected@file@percent }
175179
\@writefile{lof}{\addvspace {10.0pt}}
176180
\@writefile{lot}{\addvspace {10.0pt}}
177-
\@writefile{lot}{\contentsline {table}{\numberline {B.1}{33个ASCII控制字符}}{153}{table.B.1}\protected@file@percent }
178-
\newlabel{tab:B-1}{{B.1}{153}{33个ASCII控制字符}{table.B.1}{}}
181+
\@writefile{lot}{\contentsline {table}{\numberline {B.1}{33个ASCII控制字符}}{155}{table.B.1}\protected@file@percent }
182+
\newlabel{tab:B-1}{{B.1}{155}{33个ASCII控制字符}{table.B.1}{}}
179183
\gdef \LT@iv {\LT@entry
180184
{1}{33.67001pt}\LT@entry
181185
{1}{33.81001pt}\LT@entry
@@ -189,18 +193,18 @@
189193
{1}{33.67001pt}\LT@entry
190194
{1}{33.81001pt}\LT@entry
191195
{1}{26.72002pt}}
192-
\@writefile{lot}{\contentsline {table}{\numberline {B.2}{95个ASCII可打印字符}}{154}{table.B.2}\protected@file@percent }
193-
\newlabel{tab:B-2}{{B.2}{154}{95个ASCII可打印字符}{table.B.2}{}}
194-
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 C\hspace {.3em}}相关数学知识}{155}{appendix.C}\protected@file@percent }
196+
\@writefile{lot}{\contentsline {table}{\numberline {B.2}{95个ASCII可打印字符}}{156}{table.B.2}\protected@file@percent }
197+
\newlabel{tab:B-2}{{B.2}{156}{95个ASCII可打印字符}{table.B.2}{}}
198+
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 C\hspace {.3em}}相关数学知识}{157}{appendix.C}\protected@file@percent }
195199
\@writefile{lof}{\addvspace {10.0pt}}
196200
\@writefile{lot}{\addvspace {10.0pt}}
197-
\@writefile{toc}{\contentsline {section}{\numberline {C.1}数制转换}{155}{section.C.1}\protected@file@percent }
198-
\@writefile{lof}{\contentsline {figure}{\numberline {C.1}{\ignorespaces 一个简单的数字时钟}}{155}{figure.C.1}\protected@file@percent }
199-
\@writefile{lof}{\contentsline {figure}{\numberline {C.2}{\ignorespaces 从计数到乘方}}{156}{figure.C.2}\protected@file@percent }
200-
\@writefile{lof}{\contentsline {figure}{\numberline {C.3}{\ignorespaces 一个12进制乘法表}}{157}{figure.C.3}\protected@file@percent }
201-
\@writefile{lof}{\contentsline {figure}{\numberline {C.4}{\ignorespaces $(1a.c3)_{16}$的形式化表示}}{159}{figure.C.4}\protected@file@percent }
202-
\@writefile{lof}{\contentsline {figure}{\numberline {C.5}{\ignorespaces 通过短除法把十进制数转换成$R$进制}}{162}{figure.C.5}\protected@file@percent }
203-
\@writefile{lof}{\contentsline {figure}{\numberline {C.6}{\ignorespaces 二进制与八进制的转换}}{163}{figure.C.6}\protected@file@percent }
204-
\@writefile{lof}{\contentsline {figure}{\numberline {C.7}{\ignorespaces 二进制与十六进制的转换}}{164}{figure.C.7}\protected@file@percent }
205-
\@writefile{toc}{\contentsline {chapter}{跋}{165}{appendix*.121}\protected@file@percent }
206-
\gdef \@abspage@last{172}
201+
\@writefile{toc}{\contentsline {section}{\numberline {C.1}数制转换}{157}{section.C.1}\protected@file@percent }
202+
\@writefile{lof}{\contentsline {figure}{\numberline {C.1}{\ignorespaces 一个简单的数字时钟}}{157}{figure.C.1}\protected@file@percent }
203+
\@writefile{lof}{\contentsline {figure}{\numberline {C.2}{\ignorespaces 从计数到乘方}}{158}{figure.C.2}\protected@file@percent }
204+
\@writefile{lof}{\contentsline {figure}{\numberline {C.3}{\ignorespaces 一个12进制乘法表}}{159}{figure.C.3}\protected@file@percent }
205+
\@writefile{lof}{\contentsline {figure}{\numberline {C.4}{\ignorespaces $(1a.c3)_{16}$的形式化表示}}{161}{figure.C.4}\protected@file@percent }
206+
\@writefile{lof}{\contentsline {figure}{\numberline {C.5}{\ignorespaces 通过短除法把十进制数转换成$R$进制}}{164}{figure.C.5}\protected@file@percent }
207+
\@writefile{lof}{\contentsline {figure}{\numberline {C.6}{\ignorespaces 二进制与八进制的转换}}{165}{figure.C.6}\protected@file@percent }
208+
\@writefile{lof}{\contentsline {figure}{\numberline {C.7}{\ignorespaces 二进制与十六进制的转换}}{166}{figure.C.7}\protected@file@percent }
209+
\@writefile{toc}{\contentsline {chapter}{跋}{167}{appendix*.121}\protected@file@percent }
210+
\gdef \@abspage@last{174}

main.log

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex 2023.12.3) 7 JAN 2024 15:10
1+
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex 2023.12.3) 7 JAN 2024 21:21
22
entering extended mode
33
\write18 enabled.
44
file:line:error style messages enabled.
@@ -1350,48 +1350,52 @@ Overfull \hbox (13.86275pt too wide) in paragraph at lines 123--124
13501350
[][][][] \TU/SimSun(0)/m/n/10 有 一 套 动 态 调 整 容 量 的 机 制,| 如 果 要 存 储 的 数 据 量 超 过 了 原 有 的 容 量 |(比 如 说,| 用 [][][]
13511351
[]
13521352

1353-
[147]))) (././intensive_part.tex [148] [149
1353+
[147])) (./generalized_parts/07_projecting.tex [148]
1354+
第七章
1355+
(./generalized_parts/07_projecting/01_separate_compilation.tex) (./generalized_parts/07_projecting/02_scope_and_storage_duration.tex) (./generalized_parts/07_projecting/03_namespace.tex) (./generalized_parts/07_projecting/04_coding_style.tex))) (././intensive_part.tex [149
13541356

1355-
] [150]) (./other_parts/appendix.tex (./other_parts/appendices/A.tex
1357+
] [150
1358+
1359+
] [151] [152]) (./other_parts/appendix.tex (./other_parts/appendices/A.tex
13561360
附录 A
13571361

13581362
Underfull \hbox (badness 6063) in paragraph at lines 16--16
13591363
[][][]\TU/SimSun(0)/m/n/8.33344 对 于 内 置 类 型 数 组 [][][] 的 下 标 运 算,| [][][][][][] |(和 [][][][][][])| 都 会 解 析 为 [][][][][][][]
13601364
[]
13611365

1362-
[151
1366+
[153
13631367

1364-
]) (./other_parts/appendices/B.tex [152]
1368+
]) (./other_parts/appendices/B.tex [154]
13651369
附录 B
1366-
[153
1370+
[155
13671371

1368-
]) (./other_parts/appendices/C.tex [154]
1372+
]) (./other_parts/appendices/C.tex [156]
13691373
附录 C
13701374
File: appendices/../images/other_parts/C_digital_clock.png Graphic file (type bmp)
13711375
<appendices/../images/other_parts/C_digital_clock.png>
1372-
[155
1376+
[157
13731377

13741378
]
13751379
File: appendices/../images/other_parts/C_from_counting_to_exponentiation_300.png Graphic file (type bmp)
13761380
<appendices/../images/other_parts/C_from_counting_to_exponentiation_300.png>
13771381
File: appendices/../images/other_parts/C_duodecimal_multiplication_table.png Graphic file (type bmp)
13781382
<appendices/../images/other_parts/C_duodecimal_multiplication_table.png>
1379-
[156]
1383+
[158]
13801384
Underfull \vbox (badness 2753) has occurred while \output is active []
13811385

1382-
[157] [158]
1386+
[159] [160]
13831387
File: appendices/../images/other_parts/C_formatted_representation_of_a_number_300.png Graphic file (type bmp)
13841388
<appendices/../images/other_parts/C_formatted_representation_of_a_number_300.png>
1385-
[159] [160]
1389+
[161] [162]
13861390
File: appendices/../images/other_parts/C_short_division_300.png Graphic file (type bmp)
13871391
<appendices/../images/other_parts/C_short_division_300.png>
1388-
[161] [162]
1392+
[163] [164]
13891393
File: appendices/../images/other_parts/C_bin_to_oct_300.png Graphic file (type bmp)
13901394
<appendices/../images/other_parts/C_bin_to_oct_300.png>
1391-
[163]
1395+
[165]
13921396
File: appendices/../images/other_parts/C_bin_to_hex_300.png Graphic file (type bmp)
13931397
<appendices/../images/other_parts/C_bin_to_hex_300.png>
1394-
)) (./other_parts/afterword.tex [164])
1398+
)) (./other_parts/afterword.tex [166])
13951399
File: images/other_parts/back_cover.pdf Graphic file (type pdf)
13961400
<use images/other_parts/back_cover.pdf>
13971401
File: images/other_parts/back_cover.pdf Graphic file (type pdf)
@@ -1400,7 +1404,7 @@ File: images/other_parts/back_cover.pdf Graphic file (type pdf)
14001404
<use images/other_parts/back_cover.pdf, page 1>
14011405
File: images/other_parts/back_cover.pdf Graphic file (type pdf)
14021406
<use images/other_parts/back_cover.pdf, page 1>
1403-
[165
1407+
[167
14041408

14051409
]
14061410
File: images/other_parts/back_cover.pdf Graphic file (type pdf)
@@ -1409,7 +1413,7 @@ File: images/other_parts/back_cover.pdf Graphic file (type pdf)
14091413
<use images/other_parts/back_cover.pdf, page 1>
14101414
File: images/other_parts/back_cover.pdf Graphic file (type pdf)
14111415
<use images/other_parts/back_cover.pdf, page 1>
1412-
[166] (./main.aux)
1416+
[168] (./main.aux)
14131417
***********
14141418
LaTeX2e <2023-11-01>
14151419
L3 programming layer <2022/08/05>
@@ -1418,16 +1422,22 @@ L3 programming layer <2022/08/05>
14181422

14191423
LaTeX Font Warning: Some font shapes were not available, defaults substituted.
14201424

1421-
Package rerunfilecheck Info: File `main.out' has not changed.
1422-
(rerunfilecheck) Checksum: AD03189C31979B328A090F5BD08986B6;4808.
1425+
1426+
Package rerunfilecheck Warning: File `main.out' has changed.
1427+
(rerunfilecheck) Rerun to get outlines right
1428+
(rerunfilecheck) or use package `bookmark'.
1429+
1430+
Package rerunfilecheck Info: Checksums for `main.out':
1431+
(rerunfilecheck) Before: DC6BEB0681930F66536DDFBF9EC9C84B;4891
1432+
(rerunfilecheck) After: 0B942EFB5E4701AAF5BCA8E3954D8AAB;4986.
14231433
)
14241434
Here is how much of TeX's memory you used:
1425-
26129 strings out of 474924
1426-
640773 string characters out of 5765037
1435+
26166 strings out of 474924
1436+
642629 string characters out of 5765037
14271437
1995189 words of memory out of 5000000
1428-
47389 multiletter control sequences out of 15000+600000
1438+
47408 multiletter control sequences out of 15000+600000
14291439
571813 words of font info for 164 fonts, out of 8000000 for 9000
14301440
1348 hyphenation exceptions out of 8191
14311441
93i,17n,111p,1239b,1852s stack positions out of 10000i,1000n,20000p,200000b,200000s
14321442

1433-
Output written on main.pdf (172 pages).
1443+
Output written on main.pdf (174 pages).

main.out

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939
\BOOKMARK [1][-]{section.6.3}{\376\377\133\236\144\315\377\032\165\050\176\323\147\204\117\123\133\236\163\260\123\125\224\376\210\150}{chapter.6}% 39
4040
\BOOKMARK [1][-]{section.6.4}{\376\377\200\124\124\010\117\123}{chapter.6}% 40
4141
\BOOKMARK [1][-]{section.6.5}{\376\377\174\173\122\035\153\145}{chapter.6}% 41
42-
\BOOKMARK [-1][-]{part*.113}{\376\377\174\276\213\262\173\307}{}% 42
43-
\BOOKMARK [0][-]{appendix.A}{\376\377\000C\000+\000+\217\320\173\227\173\046\127\372\147\054\134\136\140\047}{part*.113}% 43
44-
\BOOKMARK [0][-]{appendix.B}{\376\377\000A\000S\000C\000I\000I\170\001\210\150\377\010\0000\122\060\0001\0002\0007\377\011}{part*.113}% 44
45-
\BOOKMARK [0][-]{appendix.C}{\376\377\166\370\121\163\145\160\133\146\167\345\213\306}{part*.113}% 45
46-
\BOOKMARK [1][-]{section.C.1}{\376\377\145\160\122\066\217\154\143\142}{appendix.C}% 46
47-
\BOOKMARK [0][-]{appendix*.121}{\376\377\215\313}{part*.113}% 47
42+
\BOOKMARK [0][-]{chapter.7}{\376\377\116\343\170\001\135\345\172\013}{part*.3}% 42
43+
\BOOKMARK [1][-]{section.7.1}{\376\377\215\350\145\207\116\366\177\026\213\321}{chapter.7}% 43
44+
\BOOKMARK [-1][-]{part*.113}{\376\377\174\276\213\262\173\307}{}% 44
45+
\BOOKMARK [0][-]{appendix.A}{\376\377\000C\000+\000+\217\320\173\227\173\046\127\372\147\054\134\136\140\047}{part*.113}% 45
46+
\BOOKMARK [0][-]{appendix.B}{\376\377\000A\000S\000C\000I\000I\170\001\210\150\377\010\0000\122\060\0001\0002\0007\377\011}{part*.113}% 46
47+
\BOOKMARK [0][-]{appendix.C}{\376\377\166\370\121\163\145\160\133\146\167\345\213\306}{part*.113}% 47
48+
\BOOKMARK [1][-]{section.C.1}{\376\377\145\160\122\066\217\154\143\142}{appendix.C}% 48
49+
\BOOKMARK [0][-]{appendix*.121}{\376\377\215\313}{part*.113}% 49

0 commit comments

Comments
 (0)