Skip to content

Commit 754ddbc

Browse files
committed
Started Chapter 8
1 parent b85d8e2 commit 754ddbc

17 files changed

+146
-88
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
> *cppHusky* 的2024年礼
44
5-
### 此项目已经开始
5+
### 此项目第一阶段计划(泛讲篇前七章)已经完成
66

7-
当前进度:泛讲篇第六章完成。参见[Preview](https://github.com/cppHusky/cppHusky-cpp-Tutorial/releases/tag/preview)
7+
当前进度:泛讲篇第七章完成。参见[Preview](https://github.com/cppHusky/cppHusky-cpp-Tutorial/releases/tag/preview)
88

99
我为此规划了一个大致的编章结构,参见[Structure.md](https://github.com/cppHusky/cppHusky-cpp-Tutorial/blob/main/Structure.md)
1010

11-
正在疯狂赶进度,还要画插图,还要期末考试。现阶段争取保持每4天更新一章的速度
11+
正在疯狂赶进度,还要补充插图。现阶段争取保持每3天更新一章的速度
1212

1313
如果发现内容有任何疏漏和错误,欢迎来作补充和提出修改意见!可以直接提交到[Issues](https://github.com/cppHusky/cppHusky-cpp-Tutorial/issues)当中。

generalized_part.tex

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ \part*{泛讲篇}
66
\import{generalized_parts/}{04_introduction_to_functions.tex}
77
\import{generalized_parts/}{05_compound_types_and_their_use.tex}
88
\import{generalized_parts/}{06_custom_types_and_their_use.tex}
9-
\import{generalized_parts/}{07_projecting.tex}
9+
\import{generalized_parts/}{07_projecting.tex}
10+
\import{generalized_parts/}{08_a_step_forward_in_classes_and_functions.tex}

generalized_parts/07_projecting/01_separate_compilation.tex

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ \section{跨文件编译}
3131
using namespace std; //使用命名空间std
3232
void input_clear(istream& = {cin}); //在声明中就给出默认参数
3333
\end{lstlisting}
34-
其中的 \lstinline@#pragma once@ 是另一种预处理指令,它保证这个头文件只被包含一次,而不致违反单一定义规则\footnote{单一定义规则(One definition rule, ODR),即任何变量、函数和自定义类型(包括枚举)在每个翻译单元中都可以有多个声明,但只能有一个定义。}。如果你的编译器不支持这种 \lstinline@#pragma once@ 语法,你也可以这么写:
34+
其中的 \lstinline@#pragma once@ 是另一种预处理指令,它保证这个头文件只被包含一次,而不致违反单一定义规则\footnote{单一定义规则(One definition rule, ODR),即任何变量、函数和自定义类型(包括枚举)在每个翻译单元中都可以有多个声明,但只能有一个定义。}。较现代的编译器一般支持这种语法;但如果你的编译器不支持
35+
\lstinline@#pragma once@,你也可以这么写:
3536
\begin{lstlisting}
36-
#ifndef _Header_ //名字随便起
37+
#ifndef _Header_ //名字随便起,但要防止撞其它的名字
3738
#define _Header_
3839
//...这里是头文件的代码部分
3940
#endif //与#ifndef配对
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
\chapter{类与函数进阶}
2+
到第七章结束,读者应当已经掌握了C++语言的必要知识,并具备了独立搭建简单C++工程的能力。因此从本章开始,我也会略微转换讲解风格,不再用长篇累牍的知识点,大水漫灌。我将带领读者,从一些简单的例子开始练习,进而完成一个类,一个类模版,或是一系列函数,从而实现一些功能。\par
3+
我的目标是,在本章的结尾带领读者写出一个简化版的 \lstinline@string@ 类。C++的 \lstinline@string@ 库中已经有这个类,按理说不需要我们实现。但是,``会用''``会写''还是不一样的!在用的时候,我们对很多陷阱一无所知,对很多问题浑然不觉——这恰恰是封装良好的优点,我们使用某个功能时无需在这些杂碎问题上浪费不必要的时间——一旦自己从头开始搭建,这些问题就会纷纷暴露出来。\par
4+
只有用过了知识,我们才能掌握;只有暴露了问题,我们才能进步。任何一门编程语言都是如此,C++更不例外。\par
5+
\import{08_a_step_forward_in_classes_and_functions/}{01_operator_overloading.tex}
6+
\import{08_a_step_forward_in_classes_and_functions/}{02_friend.tex}
7+
\import{08_a_step_forward_in_classes_and_functions/}{03_constructor_and_destructor.tex}
8+
\import{08_a_step_forward_in_classes_and_functions/}{04_property_of_member.tex}
9+
\import{08_a_step_forward_in_classes_and_functions/}{05_array_of_objects_and_pointer_to_object.tex}
10+
\import{08_a_step_forward_in_classes_and_functions/}{06_type_cast_operator.tex}
11+
\import{08_a_step_forward_in_classes_and_functions/}{07_exercise_string_class.tex}

generalized_parts/08_a_step_forward_in_classes_and_functions/01_operator_overloading.tex

Whitespace-only changes.

generalized_parts/08_a_step_forward_in_classes_and_functions/02_friend.tex

Whitespace-only changes.

generalized_parts/08_a_step_forward_in_classes_and_functions/03_constructor_and_destructor.tex

Whitespace-only changes.

generalized_parts/08_a_step_forward_in_classes_and_functions/04_property_of_member.tex

Whitespace-only changes.

generalized_parts/08_a_step_forward_in_classes_and_functions/05_array_of_objects_and_pointer_to_object.tex

Whitespace-only changes.

generalized_parts/08_a_step_forward_in_classes_and_functions/06_type_cast_operator.tex

Whitespace-only changes.

generalized_parts/08_a_step_forward_in_classes_and_functions/07_exercise_string_class.tex

Whitespace-only changes.

main.aux

+24-21
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,22 @@
163163
\@writefile{toc}{\contentsline {section}{\numberline {7.3}作用域、存储期和链接}{159}{section.7.3}\protected@file@percent }
164164
\@writefile{toc}{\contentsline {section}{\numberline {7.4}编码风格}{165}{section.7.4}\protected@file@percent }
165165
\@writefile{lof}{\contentsline {figure}{\numberline {7.3}{\ignorespaces 飞行模拟器(1998年IOCCC获奖作品)的代码}}{166}{figure.7.3}\protected@file@percent }
166+
\@writefile{toc}{\contentsline {chapter}{\numberline {第八章\hspace {.3em}}类与函数进阶}{171}{chapter.8}\protected@file@percent }
167+
\@writefile{lof}{\addvspace {10.0pt}}
168+
\@writefile{lot}{\addvspace {10.0pt}}
166169
\gdef \LT@ii {\LT@entry
167170
{1}{42.00002pt}\LT@entry
168171
{1}{136.19997pt}\LT@entry
169172
{1}{117.00002pt}\LT@entry
170173
{1}{52.00002pt}\LT@entry
171174
{1}{82.00002pt}}
172-
\@writefile{toc}{\contentsline {part}{精讲篇}{173}{part*.124}\protected@file@percent }
173-
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 A\hspace {.3em}}C++运算符基本属性}{173}{appendix.A}\protected@file@percent }
175+
\@writefile{toc}{\contentsline {part}{精讲篇}{175}{part*.124}\protected@file@percent }
176+
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 A\hspace {.3em}}C++运算符基本属性}{175}{appendix.A}\protected@file@percent }
174177
\@writefile{lof}{\addvspace {10.0pt}}
175178
\@writefile{lot}{\addvspace {10.0pt}}
176-
\newlabel{ch:appendix_A}{{A}{173}{C++运算符基本属性}{appendix.A}{}}
177-
\@writefile{lot}{\contentsline {table}{\numberline {A.1}{截至C++17的所有运算符}}{173}{table.A.1}\protected@file@percent }
178-
\newlabel{tab:A-1}{{A.1}{173}{截至C++17的所有运算符}{table.A.1}{}}
179+
\newlabel{ch:appendix_A}{{A}{175}{C++运算符基本属性}{appendix.A}{}}
180+
\@writefile{lot}{\contentsline {table}{\numberline {A.1}{截至C++17的所有运算符}}{175}{table.A.1}\protected@file@percent }
181+
\newlabel{tab:A-1}{{A.1}{175}{截至C++17的所有运算符}{table.A.1}{}}
179182
\gdef \LT@iii {\LT@entry
180183
{1}{33.67001pt}\LT@entry
181184
{1}{33.81001pt}\LT@entry
@@ -187,11 +190,11 @@
187190
{1}{26.72002pt}\LT@entry
188191
{1}{27.283pt}\LT@entry
189192
{1}{86.44002pt}}
190-
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 B\hspace {.3em}}ASCII码表(0到127)}{175}{appendix.B}\protected@file@percent }
193+
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 B\hspace {.3em}}ASCII码表(0到127)}{177}{appendix.B}\protected@file@percent }
191194
\@writefile{lof}{\addvspace {10.0pt}}
192195
\@writefile{lot}{\addvspace {10.0pt}}
193-
\@writefile{lot}{\contentsline {table}{\numberline {B.1}{33个ASCII控制字符}}{175}{table.B.1}\protected@file@percent }
194-
\newlabel{tab:B-1}{{B.1}{175}{33个ASCII控制字符}{table.B.1}{}}
196+
\@writefile{lot}{\contentsline {table}{\numberline {B.1}{33个ASCII控制字符}}{177}{table.B.1}\protected@file@percent }
197+
\newlabel{tab:B-1}{{B.1}{177}{33个ASCII控制字符}{table.B.1}{}}
195198
\gdef \LT@iv {\LT@entry
196199
{1}{33.67001pt}\LT@entry
197200
{1}{33.81001pt}\LT@entry
@@ -205,18 +208,18 @@
205208
{1}{33.67001pt}\LT@entry
206209
{1}{33.81001pt}\LT@entry
207210
{1}{26.72002pt}}
208-
\@writefile{lot}{\contentsline {table}{\numberline {B.2}{95个ASCII可打印字符}}{176}{table.B.2}\protected@file@percent }
209-
\newlabel{tab:B-2}{{B.2}{176}{95个ASCII可打印字符}{table.B.2}{}}
210-
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 C\hspace {.3em}}相关数学知识}{177}{appendix.C}\protected@file@percent }
211+
\@writefile{lot}{\contentsline {table}{\numberline {B.2}{95个ASCII可打印字符}}{178}{table.B.2}\protected@file@percent }
212+
\newlabel{tab:B-2}{{B.2}{178}{95个ASCII可打印字符}{table.B.2}{}}
213+
\@writefile{toc}{\contentsline {chapter}{\numberline {附录 C\hspace {.3em}}相关数学知识}{179}{appendix.C}\protected@file@percent }
211214
\@writefile{lof}{\addvspace {10.0pt}}
212215
\@writefile{lot}{\addvspace {10.0pt}}
213-
\@writefile{toc}{\contentsline {section}{\numberline {C.1}数制转换}{177}{section.C.1}\protected@file@percent }
214-
\@writefile{lof}{\contentsline {figure}{\numberline {C.1}{\ignorespaces 一个简单的数字时钟}}{177}{figure.C.1}\protected@file@percent }
215-
\@writefile{lof}{\contentsline {figure}{\numberline {C.2}{\ignorespaces 从计数到乘方}}{178}{figure.C.2}\protected@file@percent }
216-
\@writefile{lof}{\contentsline {figure}{\numberline {C.3}{\ignorespaces 一个12进制乘法表}}{179}{figure.C.3}\protected@file@percent }
217-
\@writefile{lof}{\contentsline {figure}{\numberline {C.4}{\ignorespaces $(1a.c3)_{16}$的形式化表示}}{181}{figure.C.4}\protected@file@percent }
218-
\@writefile{lof}{\contentsline {figure}{\numberline {C.5}{\ignorespaces 通过短除法把十进制数转换成$R$进制}}{184}{figure.C.5}\protected@file@percent }
219-
\@writefile{lof}{\contentsline {figure}{\numberline {C.6}{\ignorespaces 二进制与八进制的转换}}{185}{figure.C.6}\protected@file@percent }
220-
\@writefile{lof}{\contentsline {figure}{\numberline {C.7}{\ignorespaces 二进制与十六进制的转换}}{186}{figure.C.7}\protected@file@percent }
221-
\@writefile{toc}{\contentsline {chapter}{跋}{187}{appendix*.132}\protected@file@percent }
222-
\gdef \@abspage@last{194}
216+
\@writefile{toc}{\contentsline {section}{\numberline {C.1}数制转换}{179}{section.C.1}\protected@file@percent }
217+
\@writefile{lof}{\contentsline {figure}{\numberline {C.1}{\ignorespaces 一个简单的数字时钟}}{179}{figure.C.1}\protected@file@percent }
218+
\@writefile{lof}{\contentsline {figure}{\numberline {C.2}{\ignorespaces 从计数到乘方}}{180}{figure.C.2}\protected@file@percent }
219+
\@writefile{lof}{\contentsline {figure}{\numberline {C.3}{\ignorespaces 一个12进制乘法表}}{181}{figure.C.3}\protected@file@percent }
220+
\@writefile{lof}{\contentsline {figure}{\numberline {C.4}{\ignorespaces $(1a.c3)_{16}$的形式化表示}}{183}{figure.C.4}\protected@file@percent }
221+
\@writefile{lof}{\contentsline {figure}{\numberline {C.5}{\ignorespaces 通过短除法把十进制数转换成$R$进制}}{186}{figure.C.5}\protected@file@percent }
222+
\@writefile{lof}{\contentsline {figure}{\numberline {C.6}{\ignorespaces 二进制与八进制的转换}}{187}{figure.C.6}\protected@file@percent }
223+
\@writefile{lof}{\contentsline {figure}{\numberline {C.7}{\ignorespaces 二进制与十六进制的转换}}{188}{figure.C.7}\protected@file@percent }
224+
\@writefile{toc}{\contentsline {chapter}{跋}{189}{appendix*.132}\protected@file@percent }
225+
\gdef \@abspage@last{196}

0 commit comments

Comments
 (0)