{"id":1370,"date":"2015-01-26T21:19:18","date_gmt":"2015-01-26T12:19:18","guid":{"rendered":"http:\/\/gekko-plus.com\/?p=1370"},"modified":"2022-12-03T18:08:56","modified_gmt":"2022-12-03T09:08:56","slug":"201501-article_21-html","status":"publish","type":"post","link":"https:\/\/gekko-plus.com\/?p=1370","title":{"rendered":"C++ virtual function"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u8a18\u8ff0\u3059\u308b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u91cf\u304c\u5897\u3048\u308b\u306e\u3067\u3069\u3046\u3057\u3088\u3046\u304b\u305a\u3063\u3068\u60a9\u3093\u3067\u3044\u305f\u306e\u3060\u304c\u4eee\u60f3\u95a2\u6570\u3092\u4f7f\u3048\u3070\u3050\u3063\u3068\u6e1b\u308a\u305d\u3046\u3060\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><code>class A {<br>\npublic:<br>\n&nbsp;&nbsp;virtual void func() = 0;<br>\n};<br>\nclass B: public A {<br>\npublic:<br>\n&nbsp;&nbsp;void func() { printf(\"B\\n\"); }<br>\n};<br>\nclass C: public A {<br>\npublic:<br>\n&nbsp;&nbsp;void func() { printf(\"C\\n\"); }<br>\n};<br>\nmain()<br>\n{<br>\n&nbsp;&nbsp;B *pb = new B;<br>\n&nbsp;&nbsp;C *pc = new C;<br>\n&nbsp;&nbsp;A *pa;<br>\n&nbsp;&nbsp;pa = pc;<br>\n&nbsp;&nbsp;pa-&gt;func();<br>\n&nbsp;&nbsp;pa = pb;<br>\n&nbsp;&nbsp;pa-&gt;func();<br>\n}<br>\n<\/code><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b9f\u884c\u3059\u308b\u3068\u3001C\u3001B\u306e\u9806\u3067\u6587\u5b57\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002pa\u306b\u4ee3\u5165\u3055\u308c\u3066\u3044\u308b\u30af\u30e9\u30b9\u306e\u30dd\u30a4\u30f3\u30bf\u306e\u578b\u3092\u6c17\u306b\u3057\u306a\u304f\u3066\u3088\u3044\u306e\u304c\u7d20\u6674\u3089\u3057\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8a18\u8ff0\u3059\u308b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u91cf\u304c\u5897\u3048\u308b\u306e\u3067\u3069\u3046\u3057\u3088\u3046\u304b\u305a\u3063\u3068\u60a9\u3093\u3067\u3044\u305f\u306e\u3060\u304c\u4eee\u60f3\u95a2\u6570\u3092\u4f7f\u3048\u3070\u3050\u3063\u3068\u6e1b\u308a\u305d\u3046\u3060\u3002 class A { public: &nbsp;&nbsp;virtual void func() = 0; };  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[4],"tags":[],"class_list":["post-1370","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/gekko-plus.com\/index.php?rest_route=\/wp\/v2\/posts\/1370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gekko-plus.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gekko-plus.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gekko-plus.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gekko-plus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1370"}],"version-history":[{"count":1,"href":"https:\/\/gekko-plus.com\/index.php?rest_route=\/wp\/v2\/posts\/1370\/revisions"}],"predecessor-version":[{"id":3612,"href":"https:\/\/gekko-plus.com\/index.php?rest_route=\/wp\/v2\/posts\/1370\/revisions\/3612"}],"wp:attachment":[{"href":"https:\/\/gekko-plus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gekko-plus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gekko-plus.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}