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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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配对
Lines changed: 11 additions & 0 deletions
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.

0 commit comments

Comments
 (0)