{"id":1736,"date":"2009-08-17T23:58:00","date_gmt":"2009-08-17T14:58:00","guid":{"rendered":"https:\/\/hdmr.org\/d\/?e=463"},"modified":"2009-08-17T23:58:00","modified_gmt":"2009-08-17T14:58:00","slug":"blogn-463","status":"publish","type":"post","link":"https:\/\/hdmr.org\/d\/?e=463","title":{"rendered":"\u7d99\u627f\u3057\u305f\u3089\u30dd\u30a4\u30f3\u30bf\u4f7f\u3063\u3066new\u3057\u306a\u3044\u3068\u4ee3\u5165\u3067\u304d\u306a\u3044\u305e"},"content":{"rendered":"<p>\u3084\u3063\u3068C++\u3067\u3084\u3063\u3066\u305f\u4e00\u9023\u306e\u4f5c\u696d\u304c\u4e00\u6bb5\u843d\u3057\u305f\u3002<br \/>\u307e\u3041\u307e\u3060\u3042\u3068\u3061\u3087\u3063\u3068\u3042\u308a\u307e\u3059\u3051\u3069\u306d\u3002<\/p>\n<hr \/>\n<p>\u305d\u3093\u306a\u4e2d\u3067\u6c17\u4ed8\u3044\u305f\u3053\u3068\u3002<\/p>\n<pre>class IFunc{<br \/>public:<br \/>  virtual void operator()(void)=0;<br \/>}<br \/>class MyFunc : public IFunc{<br \/> \/\/\u5b9f\u88c5<br \/>}<\/pre>\n<p>\u3053\u3093\u306a\u98a8\u306b\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u7528\u610f\u3059\u308b\u3068\u3002<br \/>\u307e\u3041C++\u306b\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3068\u3044\u3046\u8a00\u8449\u306f\u306a\u3044\u3060\u308d\u3046\u304c\u3001\u5225\u306b\u305d\u308c\u306f\u554f\u984c\u3067\u306f\u306a\u3044\u3060\u308d\u3046\u3002<br \/>\u3053\u3053\u3067\u8a00\u3046\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3068\u3044\u3046\u306e\u306fJava\u306a\u3069\u3067\u8a00\u3046\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3068\u540c\u3058\u6a5f\u80fd\u3092\u6709\u3059\u308b\u3082\u306e\u306e\u3053\u3068\u3060\u3002<br \/>=0\u3068\u66f8\u3051\u3070\u7d99\u627f\u5148\u3067\u5fc5\u305a\u5b9f\u88c5\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u306b\u306a\u308b\u3002<\/p>\n<hr \/>\n<p>\u3055\u3066\u3001\u3053\u308c\u3092\u4f7f\u3046\u305e\u3068\u601d\u3063\u3066\u3053\u3093\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u305f\u3002<\/p>\n<pre>IFunc f=MyFunc();<br \/>f();<\/pre>\n<p>\u7d50\u679c\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u3002IFunc\u3092\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3067\u304d\u307e\u305b\u3093\u3068\u304b\u5185\u5bb9\u3060\u3063\u305f\u3068\u601d\u3046\u3002<br \/>\u307e\u3041\u3053\u306e\u8fba\u304cJava\u30fbC#\u3068\u304b\u3084\u3063\u3066\u305f\u4eba\u304c\u6df7\u4e71\u3059\u308b\u3068\u3053\u308d\u3060\u3088\u306d\u3002<br \/>\u305d\u3082\u305d\u3082Java\u3067\u306f\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u4ee5\u5916\u3001C#\u3067\u306f\u53c2\u7167\u578b\u306f\u53c2\u7167\u3067\u8868\u3055\u308c\u308b\u308f\u3051\u3060\u3002\u305d\u3057\u3066\u5b9f\u4f53\u306fnew\u3067\u4f5c\u308b\u3002<br \/>\u4e0b\u3067\u793a\u3059C++\u3068C#\u306e\u30b3\u30fc\u30c9\u306f\u5b9f\u969b\u7684\u306b\u306f\u4f3c\u305f\u3088\u3046\u306a\u3082\u306e\u3060\u3068\u8a00\u3046\u3053\u3068\u3002<\/p>\n<pre>IFunc f=new MyFunc(); \/\/C#<br \/>IFunc* f=new MyFunc(); \/\/C++ (f\u306e\u4f7f\u7528\u7d42\u4e86\u5f8cdelete\u5fc5\u8981)<\/pre>\n<p>\u5b9f\u306e\u3068\u3053\u308d\u3053\u308c\u306a\u3089\u3070\u901a\u308b\u3002<br \/>C++\u306e\u30af\u30e9\u30b9\u3068\u3044\u3046\u306e\u306fC\u306e\u69cb\u9020\u4f53\u306b\u6bdb\u304c\u751f\u3048\u305f\u3082\u306e\u306a\u306e\u3067\u3001\u5909\u6570\u81ea\u4f53\u304c\u5b9f\u4f53\u3068\u3044\u3046C#\u306e\u5024\u578b\u306e\u3088\u3046\u306a\u3053\u3068\u3082\u3067\u304d\u308b\u3002<br \/>C++\u3067\u306f\u3069\u3046\u3057\u3066\u3082\u3053\u306e\u4f7f\u3044\u65b9\u304c\u4e00\u822c\u7684\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002\u3060\u3063\u3066new\u3067\u78ba\u4fdd\u3057\u305f\u3089delete\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u304b\u3089\u3002<br \/>\u6700\u521d\u306b\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u3067\u306f\u305d\u308c\u3092\u3084\u308d\u3046\u3068\u3057\u3066\u3044\u308b\u308f\u3051\u3060\u3002<br \/>\u3051\u3069C#\u3067\u306f\u5024\u578b\u3067\u3042\u308b\u69cb\u9020\u4f53\u306f\u30af\u30e9\u30b9\u306b\u975e\u5e38\u306b\u4f3c\u3066\u3044\u308b\u3051\u3069\u7d99\u627f\u7981\u6b62\u306b\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\u3053\u308c\u306f\u3001T1\u69cb\u9020\u4f53\u306b\u306fa,b\u3068\u3044\u3046\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u3042\u3063\u3066\u3001\u3053\u308c\u3092\u7d99\u627f\u3057\u305fT2\u69cb\u9020\u4f53\u306b\u306f\u3053\u308c\u306bc\u3068\u3044\u3046\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8db3\u3057\u305f\u3002<br \/>\u305d\u3057\u305f\u3089T2\u69cb\u9020\u4f53\u306e\u5b9f\u4f53\u3092T1\u69cb\u9020\u4f53\u306e\u5909\u6570\u306b\u5165\u308c\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3088\u306d\u3002<br \/>C++\u3067\u306f\u3053\u3046\u3044\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3060\u3051\u3069\u3001\u3044\u3056\u4ee3\u5165\u3057\u3066\u307f\u3088\u3046\u3068\u3059\u308b\u3068\u4e0a\u306e\u3088\u3046\u306b\u3072\u3063\u304b\u304b\u308b\u3002<br \/>\u5b9f\u306b\u305d\u3046\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<hr \/>\n<p>\u3058\u3083\u3042\u3069\u3046\u3057\u305f\u304b\u3068\u3044\u3046\u3068\u3001new\u3067\u78ba\u4fdd\u3059\u308b\u3057\u304b\u306a\u3044\u3067\u3068\u3002<br \/>\u3068\u306f\u3044\u3048\u7834\u68c4\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3082\u96e3\u3057\u3044\u306e\u3067\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u305f\u3002<br \/>\u3042\u3068\u5b9f\u969b\u306b\u3084\u308a\u305f\u304b\u3063\u305f\u306e\u306fstd::vector\u306b\u8a70\u3081\u8fbc\u3080\u3053\u3068\u306a\u306e\u3067\u2026\u2026<\/p>\n<pre>std::vector&lt;boost::shared_ptr&lt;IFunc>> funcs;<br \/>funcs.push_back(boost::shared_ptr&lt;IFunc>(new MyFunc());<\/pre>\n<p>\u3042\u30fc\u3001\u3081\u3093\u3069\u304f\u3055\u3044\u3002<\/p>\n<hr \/>\n<p>\u305d\u3046\u3044\u3048\u3070boost\u306bboost::ptr_vector\u3068\u304b\u3044\u3046\u5909\u306a\u30b3\u30f3\u30c6\u30ca\u304c\u3042\u308b\u3093\u3060\u3088\u306d\u3002<br \/>\u3053\u308c\u306fpush_back\u3067\u30dd\u30a4\u30f3\u30bf\u3092\u6295\u3052\u8fbc\u3093\u3060\u3089at\u3067\u306f\u30c7\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3057\u305f\u7d50\u679c\u304c\u51fa\u3066\u304f\u308b\u3068\u8a00\u3046\u3084\u3064\u3002<br \/>\u305d\u3057\u3066\u30b3\u30f3\u30c6\u30ca\u304c\u7834\u68c4\u3055\u308c\u308b\u3068\u304d\u306b\u4e2d\u8eab\u3082\u7834\u68c4\u3055\u308c\u308b\u3068\u3002<br \/>\u306a\u3093\u3067\u30dd\u30a4\u30f3\u30bf\u6295\u3052\u8fbc\u3093\u3060\u306e\u306b\u30dd\u30a4\u30f3\u30bf\u51fa\u3066\u3053\u306a\u3044\u306e\u3055\u3002\u3068\u3044\u3046\u308f\u3051\u3067\u50d5\u306f\u3042\u3093\u307e\u308a\u4f7f\u3063\u3066\u3044\u306a\u3044\u3002<br \/>\u3051\u3069\u3053\u308c\u306e\u610f\u7fa9\u3063\u3066\u4eca\u307f\u305f\u3044\u306a\u4f8b\u306b\u3042\u308b\u306e\u3088\u306d\u3002<br \/><a href=\"http:\/\/www.kmonos.net\/alang\/boost\/classes\/pointer_container.html\">Let&#8217;s Boost\u306e\u8aac\u660e<\/a>\u306b\u306f\u300c\u591a\u614b\u3057\u305f\u3044\u306e\u3067vector<t>\u3067\u306f\u30c0\u30e1\u306a\u306e\u3060\u3051\u3069(\u7565)\u3068\u3044\u3046\u72b6\u6cc1\u3067ptr_vector\u3092\u4f7f\u3046\u3068\u3044\u3046\u7528\u9014\u304c\u60f3\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u300d\u3068\u66f8\u304b\u308c\u3066\u3044\u308b\u3002<br \/>\u3059\u306a\u308f\u3061\u672c\u97f3\u3092\u8a00\u3046\u3068std::vector<ifunc>\u3092\u4f7f\u3044\u305f\u3044\u304c\u305d\u308c\u306f\u53f6\u308f\u306a\u3044\u3068\u3002<br \/>\u305d\u3093\u306a\u3068\u304d\u306bboost::ptr_vector<ifunc>\u3092\u4f7f\u3063\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u3001<br \/>\u6295\u3052\u8fbc\u3080\u3068\u304d\u3060\u3051new\u3067\u3084\u3063\u3066\u3082\u3089\u3048\u3070\u3042\u3068\u306fstd::vector<ifunc>\u3067\u601d\u3063\u3066\u305f\u3068\u304a\u308a\u306b\u3044\u3051\u308b\u3093\u3058\u3083\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3068\u3002<br \/>\u305d\u3046\u3044\u3046\u3053\u3068\u304b\u306a\u3068\u3002\u306a\u308b\u307b\u3069\u306d\u3002\u3057\u304b\u3057\u305d\u308c\u4ee5\u5916\u4f7f\u3044\u9053\u306a\u3044\u3058\u3083\u306a\u3044\u304b\u3002<br \/>\u3061\u3087\u3063\u3068\u8003\u3048\u3066\u307f\u307e\u3059\u308f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3084\u3063\u3068C++\u3067\u3084\u3063\u3066\u305f\u4e00\u9023\u306e\u4f5c\u696d\u304c\u4e00\u6bb5\u843d\u3057\u305f\u3002\u307e\u3041\u307e\u3060\u3042\u3068\u3061\u3087\u3063\u3068\u3042\u308a\u307e\u3059\u3051\u3069\u306d\u3002 \u305d\u3093\u306a\u4e2d\u3067\u6c17\u4ed8\u3044\u305f\u3053\u3068\u3002 class IFunc{public: virtual void operator()(void)=0;}cl [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1736","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1736"}],"version-history":[{"count":0,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1736\/revisions"}],"wp:attachment":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}