Skip to content

Commit 5d3176e

Browse files
add cpp
1 parent ca63271 commit 5d3176e

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed

_posts/work/technology/cpp/cpp.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# cpp
2+
3+
## 构造函数
4+
5+
### 构造函数互相调用需要使用初始化列表
6+
7+
### 父类的构造函数
8+
9+
- 子类的构造函数默认会调用父类的无参的构造函数
10+
- 如果子类的构造函数调用父类的有参的构造函数,不会再调用无参的构造函数
11+
- 如果父类没有无参的构造函数,并且有有参的构造函数,子类必须显示调用父类的有参的构造函数
12+
- 如果父类没有任何构造函数,子类也不会调用
13+
14+
### 父类和子类的构造和析构的顺序
15+
16+
## 多态
17+
18+
### 父类指针指向子类对象
19+
20+
### 实现多态:使用虚函数来`virtual`实现重写`override`
21+
22+
### 子类的重写方法里面调用父类的成员函数
23+
24+
### 需要将析构函数声明为虚函数
25+
26+
### 纯虚函数:没有函数体,且初始化为0的虚函数,可以用来定义接口
27+
28+
- 抽象类,不可以实例化,
29+
- 可以包含非纯虚函数和成员变量
30+
- 如果父类是抽象类,但是子类没有完全把所有的虚函数重写,那么子类也是抽象类,也不可以实例化
31+
32+
## static(静态成员)可以修饰函数和变量
33+
34+
### 修饰成员变量
35+
36+
- 内存在整个程序运行过程中只有一份,对比全局变量,相当于增加了作用域
37+
- 必须在类外面进行初始化
38+
39+
### 修饰成员函数
40+
41+
- 不能是虚函数
42+
- 声明和实现分离的时候,实现部分不能带static
43+
44+
### static的应用:单例
45+
46+
## const 成员
47+
48+
### const 成员变量
49+
50+
- 必须在类里面进行初始化
51+
- const对象不能修改成员变量
52+
53+
### const 成员函数:需要非静态的成员函数
54+
55+
- `const`写在参数列表后面
56+
- 声明和实现分离的时候,两边都需要写上`const`
57+
- 不能修改普通成员变量的
58+
- 只能调用`const`成员函数或者`static`函数
59+
- 但是非const函数可以调用const函数
60+
- const函数和非const函数构成重载
61+
- 非const对象优先调用非const函数
62+
- const对象只能调用`const`函数,或者`static`函数
63+
64+
## 引用类型成员
65+
66+
- 声明的时候初始化
67+
- 通过初始化列表初始化
68+
69+
## 拷贝构造函数
70+
71+
- 利用一个已经存在的对象创建一个新的对象
72+
73+
```cpp
74+
Car(const Car &car){
75+
76+
}
77+
```
78+
79+
- 如果需要拷贝所有的成员变量,没必要写拷贝构造函数
80+
81+
###
82+
83+
84+
85+
86+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# [Keychain Services](https://developer.apple.com/documentation/security/keychain_services)
2+
3+
Securely store small chunks of data on behalf of the user.
4+
5+
## Overview
6+
7+
Computer users often have small secrets that they need to store securely.
8+
9+
For example, most people manage numerous online accounts.
10+
11+
Remembering a complex, unique password for each is impossible, but writing them down is both insecure and tedious.
12+
13+
Users typically respond to this situation by recycling simple passwords across many accounts, which is also insecure.
14+
15+
The keychain services API helps you solve this problem by giving your app a mechanism to store small bits of user data in an encrypted database called a keychain.
16+
17+
When you securely remember the password for them, you free the user to choose a complicated one.
18+
19+
The keychain is not limited to passwords, as shown in Figure 1.
20+
21+
Figure 1 Securing the user's secrets in a keychain
22+
23+
![keychain](https://docs-assets.developer.apple.com/published/0ddea9db46/1c9e8103-fae2-45f4-832c-c528d2e0c2f6.png)
24+
25+
You can store other secrets that the user explicitly cares about, such as credit card information or even short notes.
26+
27+
You can also store items that the user needs but may not be aware of.
28+
29+
For example, the cryptographic keys and certificates that you manage with Certificate, Key, and Trust Services enable the user to engage in secure communications and to establish trust with other users and devices.
30+
31+
You use the keychain to store these items as well.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# [Core Data](https://developer.apple.com/documentation/coredata/)
2+
3+
Persist or cache data on a single device, or sync data to multiple devices with CloudKit.
4+
5+
## Overview
6+
7+
Use Core Data to save your application’s permanent data for offline use, to cache temporary data, and to add undo functionality to your app on a single device.
8+
9+
To sync data across multiple devices in a single iCloud account, Core Data automatically mirrors your schema to a CloudKit container.
10+
11+
Through Core Data’s Data Model editor, you define your data’s types and relationships, and generate respective class definitions.
12+
13+
Core Data can then manage object instances at runtime to provide the following features.
14+
15+
## Persistence
16+
17+
Core Data abstracts the details of mapping your objects to a store, making it easy to save data from Swift and Objective-C without administering a database directly.
18+
19+
![Persistence](https://docs-assets.developer.apple.com/published/9ce9c70ee1/[email protected])
20+
21+
## Undo and redo of individual and batched changes
22+
23+
Core Data’s undo manager tracks changes and can roll them back individually, in groups, or all at once, making it easy to add undo and redo support to your app.
24+
25+
![Undo and redo](https://docs-assets.developer.apple.com/published/8d7dbc10a8/[email protected])
26+
27+
## Background data tasks
28+
29+
Perform potentially UI-blocking data tasks, like parsing JSON into objects, in the background.
30+
31+
You can then cache or store the results to reduce server roundtrips.
32+
33+
![Background](https://docs-assets.developer.apple.com/published/97484139fe/[email protected])
34+
35+
## View synchronization
36+
37+
Core Data also helps keep your views and data synchronized by providing data sources for table and collection views.
38+
39+
## Versioning and migration
40+
41+
Core Data includes mechanisms for versioning your data model and migrating user data as your app evolves.

0 commit comments

Comments
 (0)