{"id":145,"date":"2014-06-04T00:16:23","date_gmt":"2014-06-03T15:16:23","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=145"},"modified":"2019-06-27T10:42:28","modified_gmt":"2019-06-27T01:42:28","slug":"%eb%b3%b5%ec%82%ac%ec%83%9d%ec%84%b1%ec%9e%90","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=145","title":{"rendered":"\ubcf5\uc0ac\uc0dd\uc131\uc790"},"content":{"rendered":"\n<pre class=\"lang:c++ decode:true \" >#include \"stdafx.h\"\r\n#include &lt;string.h&gt;\r\n#include &lt;conio.h&gt;\r\n\r\n#define DEBUG\r\n\r\nclass CStr{\r\n    char* str;\r\npublic:\r\n\tCStr(char *s=\"\"){\r\n\t\tstr = new char[strlen(s)+1];\r\n\t\tstrcpy(str,s);\r\n\t\tprintf(\"construction\\n\");\r\n\t}\r\n\tCStr(const CStr &amp;s){\r\n\t\tstr = new char[strlen(s.Get())+1];\r\n\t\tstrcpy(str,s.Get());\/\/const \uac1d\uccb4\ub294 const \uba64\ubc84 \ud568\uc218\ub9cc\uc744 \ud638\ucd9c\ud560 \uc218 \uc788\ub2e4.\r\n\t\tprintf(\"construction\\n\");\r\n\t}\r\n\t~CStr() {\r\n\t\tdelete[] str;\r\n\t\tprintf(\"destructor\\n\");\r\n\t}\r\n\tchar* Get() const{\r\n\t\treturn str;\r\n\t}\r\n\r\n\tvoid Print() {printf(\"%s\\n\", str);}\r\n};\r\n\r\nvoid f(CStr s){\r\n\ts.Print();\r\n}\r\n\r\n\r\nvoid main()\r\n{\r\n\tCStr s(\"hello\");\r\n\tf(s);\r\n\r\n#ifdef DEBUG\r\n\t\/\/cmd\r\n\tchar c;\r\n\tscanf(\"%c\",&amp;c);\r\n#endif\r\n}<\/pre>\n<p>\ubcf5\uc0ac \uc0dd\uc131\uc790\uac00 \ud638\ucd9c\ub418\ub294 \uacbd\uc6b0<br \/>\n1. \ud568\uc218\uc758 \ud30c\ub77c\ubbf8\ud130\ub85c \uac1d\uccb4\ub97c \uc804\ub2ec<br \/>\n2. \ud568\uc218\uac00 \uac1d\uccb4\ub97c \ub9ac\ud134<br \/>\n3. \uac1d\uccb4\uc758 \uc120\uc5b8\uc5d0 \uc0ac\uc6a9\ub41c \ub300\uc785 \uc5f0\uc0b0\uc790<br \/>\n4. \uc784\uc2dc \uac1d\uccb4\uc758 \ubcf5\uc0ac<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#include &#8220;stdafx.h&#8221; #include &lt;string.h&gt; #include &lt;conio.h&gt; #define DEBUG class CStr{ char* str; public: CStr(char *s=&#8221;&#8221;){ str = new char[strlen(s)+1]; strcpy(str,s); printf(&#8220;construction\\n&#8221;); } CStr(const CStr &amp;s){ str = new char[strlen(s.Get())+1]; strcpy(str,s.Get());\/\/const \uac1d\uccb4\ub294 const \uba64\ubc84 \ud568\uc218\ub9cc\uc744 \ud638\ucd9c\ud560 \uc218 \uc788\ub2e4. printf(&#8220;construction\\n&#8221;); } ~CStr() { delete[] str; printf(&#8220;destructor\\n&#8221;); } char* Get() const{ return str; } void Print() {printf(&#8220;%s\\n&#8221;, str);}\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=145\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-145","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=145"}],"version-history":[{"count":5,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions"}],"predecessor-version":[{"id":541,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions\/541"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}