diff --git a/.obsidian/workspace b/.obsidian/workspace index 02eec63..71fa1a2 100644 --- a/.obsidian/workspace +++ b/.obsidian/workspace @@ -10,7 +10,7 @@ "state": { "type": "markdown", "state": { - "file": "01. Daily/2022-06-06(週一).md", + "file": "02. PARA/03. Resources(資源)/C++17/智慧指標.md", "mode": "source", "source": true } @@ -23,7 +23,7 @@ "state": { "type": "outline", "state": { - "file": "01. Daily/2022-06-06(週一).md" + "file": "02. PARA/03. Resources(資源)/C++17/智慧指標.md" } } } @@ -52,7 +52,7 @@ "state": { "type": "search", "state": { - "query": "gitea", + "query": "shared_ptr", "matchingCase": false, "explainSearch": false, "collapseAll": false, @@ -81,7 +81,7 @@ "state": { "type": "backlink", "state": { - "file": "01. Daily/2022-06-06(週一).md", + "file": "02. PARA/03. Resources(資源)/C++17/智慧指標.md", "collapseAll": true, "extraContext": true, "sortOrder": "alphabetical", @@ -125,6 +125,7 @@ }, "active": "94f0e8a81af6c9e2", "lastOpenFiles": [ + "02. PARA/03. Resources(資源)/C++17/智慧指標.md", "01. Daily/2022-06-06(週一).md", "02. PARA/03. Resources(資源)/99. templates/日記.md", "02. PARA/04. Archives(歸檔)/01. Project(專案)/004. Group firmware update check.md", @@ -133,7 +134,6 @@ "00. TOP/01. TODO.md", "00. TOP/00. Inbox.md", "README.md", - "test.md", - "02. PARA/03. Resources(資源)/Proxmox VE.md" + "test.md" ] } \ No newline at end of file diff --git a/02. PARA/03. Resources(資源)/C++17/智慧指標.md b/02. PARA/03. Resources(資源)/C++17/智慧指標.md new file mode 100644 index 0000000..e476b28 --- /dev/null +++ b/02. PARA/03. Resources(資源)/C++17/智慧指標.md @@ -0,0 +1,6 @@ +unique_ptr與shared_ptr都是智慧指標,箱對於原本的raw pointer,智慧指標使用起來更方便,也不用擔心delete的問題。 + +## unique_ptr +unique_ptr的特點是,它保證在一個時間內,只會有一個指標的擁有者,也就是這個指標不能被複製跟移動,當unique_ptr離開它的scope時候,它所擁有的pointer也隨之被delete。這讓你不用擔心memoo + +## shared_ptr \ No newline at end of file