{"id":6621,"date":"2019-03-09T19:43:06","date_gmt":"2019-03-09T10:43:06","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=6621"},"modified":"2023-05-27T18:19:26","modified_gmt":"2023-05-27T09:19:26","slug":"%e3%80%90c%e3%80%91%e3%82%af%e3%83%a9%e3%82%b9%e3%81%ae%e3%82%aa%e3%83%96%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e6%a7%8b%e7%af%89%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=6621","title":{"rendered":"\u3010C++\u3011\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u69cb\u7bc9\u3084\u3001\u30e1\u30e2\u30ea\u306e\u6982\u5ff5\u3001\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u3001\u53c2\u7167\u30dd\u30a4\u30f3\u30bf"},"content":{"rendered":"<p>C++\u3067\u3082\u3001\u30af\u30e9\u30b9\u3084\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u3082\u3061\u308d\u3093\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u306e\u524d\u306b\u30e1\u30e2\u30ea\u306e\u6982\u5ff5\u3092\u62bc\u3055\u3048\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>C++\u306b\u304a\u3051\u308b\u30e1\u30e2\u30ea\u306e\u6982\u5ff5<\/h2>\n<ul>\n<li>\u81ea\u52d5\u30e1\u30e2\u30ea<\/li>\n<li>\u30d5\u30ea\u30fc\u30b9\u30c8\u30a2<\/li>\n<\/ul>\n<h3>\u81ea\u52d5\u30e1\u30e2\u30ea<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u81ea\u52d5\u7684\u306b\u7ba1\u7406\u3055\u308c\u308b\u30e1\u30e2\u30ea<\/strong><\/span>\u3067\u3059\u3002\u30b5\u30a4\u30ba\u306f\u5c0f\u3055\u3044\u3067\u3059\u3002VC++\u30671MB\u7a0b\u5ea6\u3067\u3059\u3002\u30b9\u30bf\u30c3\u30af\u30e1\u30e2\u30ea\u9818\u57df\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u7279\u306b\u660e\u793a\u7684\u306b\u958b\u653e\u3057\u306a\u304f\u3066\u3082\u3001\u30d6\u30ed\u30c3\u30af\u306e\u7d42\u308f\u308a\u3067\u89e3\u653e\u3055\u308c\u307e\u3059\u3002\uff08\u4f8b\u3048\u3070\u3001main\u95a2\u6570\u306e\u5b8c\u4e86\u6642\u306b\u89e3\u653e\u3055\u308c\u307e\u3059\u3002\uff09<\/p>\n<h3>\u30d5\u30ea\u30fc\u30b9\u30c8\u30a2<\/h3>\n<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u7ba1\u7406\u3059\u308b\u30e1\u30e2\u30ea\u9818\u57df\u3002\u30d2\u30fc\u30d7\u30e1\u30e2\u30ea\u9818\u57df\u306b\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>\u300c\u52d5\u7684\u30e1\u30e2\u30ea\u300d<\/strong><\/span>\u3068\u3082\u547c\u3070\u308c\u307e\u3059\u3002<\/p>\n<p>\u7279\u5fb4\u3068\u3057\u3066\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u81ea\u52d5\u30e1\u30e2\u30ea\u9818\u57df\u3088\u308a\u3082\u5927\u304d\u3044<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<h2>\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5ba3\u8a00\u3059\u308b\u69cb\u6587<\/h2>\n<h3>\u30dd\u30a4\u30f3\u30bf\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408<\/h3>\n<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f<span style=\"color: #ff0000;\"><strong>\u300c\u81ea\u52d5\u30e1\u30e2\u30ea\u300d<\/strong><\/span>\u306b\u914d\u7f6e\u3055\u308c\u307e\u3059\u3002<\/p>\n<h4>\u65b0\u898f\u4f5c\u6210<\/h4>\n<pre class=\"lang:default decode:true\">\u578b \u5909\u6570\u540d\r\n\u307e\u305f\u306f\r\n\u578b\u3000\u5909\u6570\u540d{}<\/pre>\n<h4>\u3059\u3067\u306b\u3042\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30b3\u30d4\u30fc\u3057\u3066\u4f5c\u6210\u3059\u308b\u5834\u5408<\/h4>\n<pre class=\"lang:default decode:true\">\u578b \u5909\u6570\u540d(\u540c\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8)\r\n\u307e\u305f\u306f\r\n\u578b \u5909\u6570\u540d{\u540c\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8}\r\n\u307e\u305f\u306f\r\n\u578b \u5909\u6570\u540d = \u540c\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\r\n<\/pre>\n<h3>\u30dd\u30a4\u30f3\u30bf(new)\u3092\u4f7f\u3046\u5834\u5408<\/h3>\n<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f<span style=\"color: #ff0000;\"><strong>\u300c\u30d5\u30ea\u30fc\u30b9\u30c8\u30a2\u300d<\/strong><\/span>\u306b\u914d\u7f6e\u3055\u308c\u307e\u3059\u3002<\/p>\n<h4>\u65b0\u898f\u4f5c\u6210<\/h4>\n<pre class=\"lang:default decode:true\">\u578b* \u30dd\u30a4\u30f3\u30bf\u5909\u6570\u540d = new \u578b\r\n\u307e\u305f\u306f\r\n\u578b* \u30dd\u30a4\u30f3\u30bf\u5909\u6570\u540d = new \u578b{}\r\n\u307e\u305f\u306f\r\n\u578b* \u30dd\u30a4\u30f3\u30bf\u5909\u6570\u540d = new \u578b()<\/pre>\n<p>\u30dd\u30a4\u30f3\u30bf\u5909\u6570\u304b\u3089\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306b\u306f\u4e0b\u8a18\u306e\u69cb\u6587\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">*\u30dd\u30a4\u30f3\u30bf\u5909\u6570\u540d<\/pre>\n<h4>\u3059\u3067\u306b\u3042\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30b3\u30d4\u30fc\u3057\u3066\u4f5c\u6210\u3059\u308b\u5834\u5408<\/h4>\n<p>\u30dd\u30a4\u30f3\u30bf\u3092\u4f7f\u3046\u5834\u5408\u3067\u3082\u30b3\u30d4\u30fc\u306f\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">\u578b* \u30dd\u30a4\u30f3\u30bf\u5909\u6570\u540d = new \u578b(\u540c\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8)\r\n\u307e\u305f\u306f\r\n\u578b* \u30dd\u30a4\u30f3\u30bf\u5909\u6570\u540d = new \u578b{\u540c\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8}<\/pre>\n<h4>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u89e3\u4f53<\/h4>\n<p><span style=\"color: #ff0000;\"><strong>\u300c\u30d5\u30ea\u30fc\u30b9\u30c8\u30a2\u300d\u306b\u914d\u7f6e\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u30d6\u30ed\u30c3\u30af\u306e\u7d42\u308f\u308a\u3067\u89e3\u4f53\u3055\u308c\u307e\u305b\u3093\u3002<\/strong><\/span><\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u660e\u793a\u7684\u306b\u958b\u653e\u3057\u3066\u3042\u3052\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u306e\u69cb\u6587\u3092\u4f7f\u3063\u3066\u3001\u5b9a\u7fa9\u3057\u305f\u30dd\u30a4\u30f3\u30bf\u5909\u6570\u3092\u89e3\u653e\u3057\u3066\u3042\u3052\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:default decode:true\">delete \u30dd\u30a4\u30f3\u30bf\u5909\u6570\u540d;<\/pre>\n<p>\u89e3\u653e\u3057\u5fd8\u308c\u308b\u3068\u3001\u30d5\u30ea\u30fc\u30b9\u30c8\u30a2\u5185\u306b\u4f7f\u308f\u308c\u306a\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u653e\u7f6e\u3055\u308c\u3066<span style=\"color: #ff0000;\"><strong>\u30e1\u30e2\u30ea\u30ea\u30fc\u30af<\/strong><\/span>\u306e\u539f\u56e0\u306b\u306a\u308b\u306e\u3067\u6ce8\u610f\u3067\u3059\u3002<\/p>\n<h2>\u300c\u81ea\u52d5\u30e1\u30e2\u30ea\u300d\u3068\u300c\u30d5\u30ea\u30fc\u30b9\u30c8\u30a2\u300d\u3067\u3069\u306e\u3088\u3046\u306b\u4f7f\u3044\u5206\u3051\u308c\u3070\u3088\u3044\u306e\u304b\uff1f<\/h2>\n<p>\u3067\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u4f5c\u6210\u306f\u3069\u3061\u3089\u306e\u5ba3\u8a00\u3082\u3067\u304d\u307e\u3059\u304c\u3001\u3069\u306e\u3088\u3046\u306b\u4f7f\u3044\u5206\u3051\u308c\u3070\u3088\u3044\u306e\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u30e1\u30e2\u30ea\u306e\u7ba1\u7406\u304c\u9762\u5012\u306a\u306e\u3067\u3001\u57fa\u672c\u7684\u306b\u306f\u81ea\u52d5\u30e1\u30e2\u30ea(new\u3092\u4f7f\u308f\u306a\u3044\u65b9)\u3092\u4f7f\u3046<\/strong><\/span>\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u305f\u3060\u3001<span style=\"color: #ff0000;\"><strong>\u81ea\u52d5\u30e1\u30e2\u30ea\u306f\u5c0f\u3055\u3044<\/strong><\/span>\u306e\u3067\u3001<span style=\"color: #ff0000;\"><strong>\u5165\u308a\u304d\u3089\u306a\u3044\u3088\u3046\u306a\u5927\u304d\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u69cb\u7bc9\u3059\u308b\u5834\u5408\u306f\u3001\u30dd\u30a4\u30f3\u30bf\u5909\u6570\u3092\u4f7f\u3063\u305f\u30d5\u30ea\u30fc\u30b9\u30c8\u30a2\u306b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u69cb\u7bc9\u3059\u308b<\/strong><\/span>\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u305f\u3060\u3001\u30d5\u30ea\u30fc\u30b9\u30c8\u30a2\u9818\u57df\u306e\u30e1\u30e2\u30ea\u7ba1\u7406\u306f\u9762\u5012\u3067\u3059\u3057\u3001\u5371\u967a\u3067\u3059\u3088\u306d\u3002\u305d\u306e\u305f\u3081\u306b\u7528\u610f\u3055\u308c\u305fC++\u306e\u6a5f\u80fd\u3067\u3042\u308b<span style=\"color: #ff0000;\"><strong>\u300c\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u300d<\/strong><\/span>\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u3068\u306f\uff1f<\/h2>\n<p>\u52d5\u7684\u306b\u7ba1\u7406\u3059\u308b\u306e\u306f\u975e\u5e38\u306b\u9762\u5012\u3067\u3059\u3002\u305d\u3053\u3067\u7528\u610f\u3055\u308c\u305f\u4ed5\u7d44\u307f\u304c<span style=\"color: #ff0000;\"><strong>\u300c\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u300d<\/strong><\/span>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u3067\u7ba1\u7406\u3055\u308c\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u81ea\u52d5\u7684\u306b\u7ba1\u7406\u3055\u308c\u308b\u305f\u3081\u3001<span style=\"color: #ff0000;\"><strong>\u660e\u793a\u7684\u306bdelete\u3092\u4f7f\u308f\u306a\u304f\u3066\u3082\u81ea\u52d5\u958b\u653e<\/strong><\/span>\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u30d8\u30c3\u30c0<\/h2>\n<p>&lt;memory&gt;\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u304a\u308a\u3001\u4e0b\u8a18\u306e\u4e8c\u7a2e\u985e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>std::unique_ptr<\/li>\n<li>std::shared_ptr<\/li>\n<\/ul>\n<h3>std::unique_ptr<\/h3>\n<p>\u30b3\u30c1\u30e9\u306e\u65b9\u304c\u65e9\u3044\u3002<\/p>\n<h3>std::shared_ptr<\/h3>\n<p>\u30b3\u30c1\u30e9\u306e\u65b9\u304c\u7c21\u5358\u306b\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<h2>\u53c2\u7167\u30dd\u30a4\u30f3\u30bf\u3068\u306f\uff1f<\/h2>\n<p>C\u8a00\u8a9e\u306b\u306f\u306a\u3044\u6a5f\u80fd\u3067\u3001\u95a2\u6570\u306e\u5f15\u6570\u306b\u30dd\u30a4\u30f3\u30bf\u3092\u6e21\u3059\u5834\u5408\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<p>\u901a\u5e38\u306e\u30dd\u30a4\u30f3\u30bf\u3067\u3042\u308c\u3070\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u95a2\u6570\u3092\u5ba3\u8a00\u3057\u305f\u5834\u5408\u306f\u3001<\/p>\n<pre class=\"lang:default decode:true\">void func(int* a);<\/pre>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306b\u6e21\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">int a;\r\nfunc(&amp;a);<\/pre>\n<p>\u305f\u3060\u3001\u300c\u53c2\u7167\u30dd\u30a4\u30f3\u30bf\u300d\u3092\u5229\u7528\u3057\u305f\u5834\u5408\u306f\u3001\u300c*\u300d\u306e\u4ee3\u308f\u308a\u306b\u300c&amp;\u300d\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">void func(int&amp; a);<\/pre>\n<p>\u6e21\u3059\u969b\u306b\u300c&amp;\u300d\u3092\u8a18\u8ff0\u3059\u308b\u5fc5\u8981\u304c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true  \">int a;\r\nfunc(a);<\/pre>\n","protected":false},"excerpt":{"rendered":"C++\u3067\u3082\u3001\u30af\u30e9\u30b9\u3084\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u3082\u3061\u308d\u3093\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u306e\u524d\u306b\u30e1\u30e2\u30ea\u306e\u6982\u5ff5\u3092\u62bc\u3055\u3048\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 C++\u306b\u304a\u3051\u308b\u30e1\u30e2\u30ea\u306e\u6982\u5ff5 \u81ea\u52d5\u30e1\u30e2\u30ea \u30d5\u30ea\u30fc\u30b9\u30c8\u30a2 \u81ea\u52d5\u30e1\u30e2\u30ea \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u81ea\u52d5\u7684\u306b\u7ba1\u7406\u3055\u308c\u308b\u30e1\u30e2\u30ea [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[76],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6621"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6621"}],"version-history":[{"count":17,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6621\/revisions"}],"predecessor-version":[{"id":20123,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6621\/revisions\/20123"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6621"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}