File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ struct CMy_add
1111 void operator ()(int val)
1212 {
1313 sum += (val & 7 );
14+ // sum = sum + (val & 7);
15+ // 注意按位与优先级低于加法!
1416 }
1517};
1618
Original file line number Diff line number Diff line change 1313
1414例:以学生为基类,派生出研究生,大学生,中学生这些子类。
1515
16- ``` c++
16+ ``` cpp
1717class 派生类名: public 基类名
1818{
1919 ...
@@ -46,7 +46,7 @@ class 派生类名: public 基类名
4646
4747例一:”圆“类包含”点“类,这是圆和点就是复合关系
4848
49- ``` c++
49+ ``` cpp
5050class Circle
5151{
5252 double radius;
@@ -56,7 +56,7 @@ class Circle
5656
5757例二:人狗关系!最好的写法是互相指向
5858
59- ``` c++
59+ ``` cpp
6060class Master ;
6161
6262class Dog
@@ -102,7 +102,7 @@ class Master
102102
103103例:
104104
105- ```c++
105+ ```cpp
106106class Father
107107{
108108private:
@@ -148,7 +148,7 @@ int main()
148148
149149### 初始化参数列表
150150
151- ``` c++
151+ ``` cpp
152152构造函数名(形参表):基类名(基类构造函数实参表)
153153{
154154 ...
@@ -180,7 +180,7 @@ int main()
180180
181181** 析构函数的调用顺序与构造函数的调用顺序相反**
182182
183- ``` c++
183+ ``` cpp
184184class Base
185185{
186186public:
@@ -225,7 +225,7 @@ int main()
225225
226226## public继承的赋值兼容规则
227227
228- ``` c++
228+ ``` cpp
229229class base {};
230230class derived : public base {};
231231base b;
@@ -240,4 +240,8 @@ derived d;
240240
241241## 直接基类和间接基类
242242
243- 在声明派生类时,只需要列出它的直接基类,派生类沿着类的层次自动向上继承它的间接基类
243+ 在声明派生类时,只需要列出它的直接基类,派生类沿着类的层次自动向上继承它的间接基类
244+
245+ ## Reference
246+
247+ https://www.coursera.org/learn/cpp-chengxu-sheji/supplement/JYzTL/ke-cheng-slides
You can’t perform that action at this time.
0 commit comments