{"id":162,"date":"2014-06-05T01:36:17","date_gmt":"2014-06-04T16:36:17","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=162"},"modified":"2019-06-27T11:15:26","modified_gmt":"2019-06-27T02:15:26","slug":"%ea%b0%80%ec%83%81-%ec%86%8c%eb%a9%b8%ec%9e%90","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=162","title":{"rendered":"\uac00\uc0c1 \uc18c\uba78\uc790"},"content":{"rendered":"\n<pre class=\"lang:c++ decode:true \" >#include \"stdafx.h\"\r\n#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n#define DEBUG\r\n\r\nclass A{\r\n    char* a;\r\npublic:\r\n\tA(char* s){\r\n\t\ta=new char[strlen(s)+1];\r\n\t\tstrcpy(a,s);\r\n\t}\r\n\tvirtual ~A(){\r\n\t\tdelete[] a;\r\n\t\tprintf(\"Destructor of class A\\n\");\r\n\t}\r\n\tvirtual void Print() \r\n\t{ \r\n\t    printf(\"%s\\n\",a);\r\n\t}\r\n};\r\n\r\nclass B : public A{\r\n\tchar* b;\r\npublic:\r\n\tB(char* s,char* t):A(t){\r\n\t\tb=new char[strlen(s)+1];\r\n\t\tstrcpy(b,s);\r\n\t}\r\n\tvirtual ~B(){\r\n\t\tdelete[]b;\r\n\t\tprintf(\"Destructor of class B\\n\");\r\n\t}\r\n\tvirtual void Print(){\r\n\t\tA::Print();\r\n\t\tprintf(\"%s\\n\",b);\r\n\t}\r\n};\r\n\r\nvoid main()\r\n{\r\n\tA* pA;\r\n\tpA=new B(\"hello\",\"world\");\r\n\tpA-&gt;Print();\r\n\tdelete pA;\r\n\r\n#ifdef DEBUG\r\n\t\/\/cmd\r\n\tchar e;\r\n\tscanf(\"%c\",&amp;e);\r\n#endif\r\n}<\/pre>\n<p>\uc0c1\uc704 \ud074\ub798\uc2a4\ub85c \uc0ac\uc6a9\ub420 \uac83 \uac19\uc740 \ud074\ub798\uc2a4\uc758 \uc0dd\uc131\uc790\uc5d0\uc11c \ub3d9\uc801\uc73c\ub85c \uba54\ubaa8\ub9ac\ub97c \ud560\ub2f9\ud558\ub294 \uacbd\uc6b0, \uc18c\uba78\uc790\ub97c \uac00\uc0c1\uc73c\ub85c \uc120\uc5b8\ud558\ub77c.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#include &#8220;stdafx.h&#8221; #include &lt;stdio.h&gt; #include &lt;string.h&gt; #define DEBUG class A{ char* a; public: A(char* s){ a=new char[strlen(s)+1]; strcpy(a,s); } virtual ~A(){ delete[] a; printf(&#8220;Destructor of class A\\n&#8221;); } virtual void Print() { printf(&#8220;%s\\n&#8221;,a); } }; class B : public A{ char* b; public: B(char* s,char* t):A(t){ b=new char[strlen(s)+1]; strcpy(b,s); } virtual ~B(){ delete[]b; printf(&#8220;Destructor of\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=162\">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-162","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\/162","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=162"}],"version-history":[{"count":2,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":548,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions\/548"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}