{"id":2017,"date":"2011-02-11T00:39:12","date_gmt":"2011-02-10T15:39:12","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/2017"},"modified":"2011-02-11T00:42:36","modified_gmt":"2011-02-10T15:42:36","slug":"%e8%aa%b0%e3%81%8b%e3%81%8c%e4%bd%bf%e3%81%a3%e3%81%9f%e3%82%89%e3%82%a2%e3%83%aa%e3%82%b9%e3%81%ab%e7%9f%a5%e3%82%89%e3%81%9b%e3%82%8d","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/2017","title":{"rendered":"\u8ab0\u304b\u304c\u4f7f\u3063\u305f\u3089\u30a2\u30ea\u30b9\u306b\u77e5\u3089\u305b\u308d"},"content":{"rendered":"<p>\n\u6012\u6d9b\u306e\u30a2\u30ea\u30d7\u30e9\u30b7\u30ea\u30fc\u30ba\u3092\u3082\u3046\u3072\u3068\u3064\u3002\n<\/p>\n<p>\n\u9784\u306b\u5bfe\u3057\u3066\u30de\u30fc\u30ad\u30f3\u30b0\u3092\u3059\u308b\u306e\u306f\u6d88\u6975\u7684\u306a\u624b\u6bb5\u3067\u3057\u3066\u3001\u30de\u30fc\u30ad\u30f3\u30b0\u3092\u4e0a\u66f8\u304d\u3055\u308c\u3066\u3057\u307e\u3063\u305f\u308a\u3001\u30de\u30fc\u30ad\u30f3\u30b0\u81ea\u4f53\u3092\u7121\u8996\u3057\u3066 Use \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u305f\u308a\u3059\u308b\u3068\u30a2\u30ea\u30b9\u306f\u304a\u624b\u4e0a\u3052\u3067\u3059\u3002\u306a\u306e\u3067\u3001\u3082\u3063\u3068\u7a4d\u6975\u7684\u306b\u9055\u6cd5\u306a Use \u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3073\u51fa\u3055\u308c\u305f\u3089\u3001\u30a2\u30e9\u30fc\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u30a2\u30ea\u30b9\u306b\u5c4a\u304f\u3088\u3046\u306b\u3057\u307e\u3059\u3002<br \/>\n\u305d\u3046\u3001mvvm \u30d1\u30bf\u30fc\u30f3\u306e INotifyPropertyChanged \u3068\u540c\u3058\u3067\u3059\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/\/ for \u8ab0\u304b\u304c\u4f7f\u3063\u305f\u3089\u30a2\u30ea\u30b9\u306b\u77e5\u3089\u305b\u308d\n\n#include &lt;iostream&gt;\n#include &lt;list&gt;\nusing namespace std;\n\nclass ICatch {\npublic:\n\tvirtual void OnTatch( void *bag ) = 0;\n};\n\nclass INotify {\nprotected:\n\tICatch *catcher;\npublic:\t\n\tvoid setCatcher( ICatch *user ) {\n\t\tcatcher = user;\n\t}\n\tvirtual void OnTatch( void *bag ) {\n\t\tif ( catcher != NULL ) {\n\t\t\tcatcher-&gt;OnTatch( bag );\n\t\t}\n\t}\n};\n\nclass Bag : public INotify {\nprotected:\n\tvoid *_mark;\npublic:\n\tBag() : _mark(NULL) {}\n\tvirtual void setMark( void *mark ) {\n\t\t\/\/ 1\u56de\u3060\u3051\u30de\u30fc\u30af\u3067\u304d\u308b\n\t\tif ( _mark == NULL ) {\n\t\t\t_mark = mark;\n\t\t}\n\t}\n\tvirtual void *getMark() {\n\t\treturn _mark;\n\t}\n\tvirtual void Used( void *user ) {\n\t\tif ( _mark != NULL &amp;&amp; _mark != user ) {\n\t\t\tOnTatch( this );\n\t\t}\n\t}\n};\n\nclass Prada : public Bag {};\nclass Tiffany : public Bag {};\n\nclass Alice : public ICatch\n{\nprivate:\n\tlist&lt;Bag*&gt; bags;\npublic:\n\tAlice() {\n\t}\n\tvoid Present( Bag *bag ) \n\t{\n\t\tif ( dynamic_cast&lt;Prada*&gt;(bag) != NULL &amp;&amp;\n             bag-&gt;getMark() == NULL ) \n\t\t{\n\t\t\tbag-&gt;setMark( this );\n\t\t\tbag-&gt;setCatcher( this );\n\t\t\tbags.push_back( bag );\n\t\t}\n\t}\n\tint CountBags() \n\t{\n\t\treturn bags.size();\n\t}\n\tvoid Use( Bag *bag ) {\n\t\tbag-&gt;Used( this );\n\t}\n\tvirtual void OnTatch( void *bag ) {\n\t\tcout &lt;&lt; &amp;quot;who use my Prada bag!!!&amp;quot; &lt;&lt; endl;\n\t}\n};\n\nclass Lolita \n{\nprivate:\n\tlist&lt;Bag*&gt; bags;\npublic:\n\tvoid Present( Bag *bag ) \n\t{\n\t\tbag-&gt;setMark( this );\n\t\tbags.push_back( bag );\n\t}\n\tvoid Use( Bag *bag ) {\n\t\tbag-&gt;Used( this );\n\t}\n};\n\nint main(void)\n{\n\tAlice alice;\n\tLolita lolita;\n\t\n\tPrada *bag = new Prada();\n\t\/\/ \u30a2\u30ea\u30b9\u306b\u30d7\u30ec\u30bc\u30f3\u30c8\n\talice.Present( bag );\n\t\/\/ \u30a2\u30ea\u30b9\u304c\u4f7f\u3046\u5206\u306b\u306f\u554f\u984c\u306a\u3057\n\talice.Use( bag );\n\t\/\/ \u540c\u3058\u9784\u3092\u30ed\u30ea\u30fc\u30bf\u306b\u30d7\u30ec\u30bc\u30f3\u30c8\n\tlolita.Present( bag );\n\t\/\/ \u30ed\u30ea\u30fc\u30bf\u304c\u9784\u3092\u4f7f\u3046\u3068...\n\tlolita.Use( bag );\n\n\treturn 0;\n}\n<\/pre>\n<p>\n\u9784(Bag)\u306e\u307b\u3046\u306b\u306f\u3001INotiry \u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u4ed5\u8fbc\u3093\u3067\u304a\u304d\u307e\u3059\u3002\u30a2\u30e9\u30fc\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u3092\u53d7\u3051\u53d6\u308b\u5074(Alice)\u306e\u307b\u3046\u306f\u3001ICatch \u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\u53d7\u3051\u53d6\u308a\u306e\u95a2\u6570\u3092\u7528\u610f\u3057\u3066\u304a\u304d\u307e\u3059\u3002C++ \u30672\u3064\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u306f C# \u306e\u30c7\u30ea\u30b2\u30fc\u30c8\u306e\u6a5f\u80fd\u304c\u306a\u3044\u306e\u3067\u3001\u3053\u3046\u306a\u3063\u3066\u3044\u307e\u3059\u3002static \u306a\u95a2\u6570\u30dd\u30a4\u30f3\u30bf\u3092\u7528\u610f\u3057\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u3069\u3046\u305b\u306a\u3089\u3070\u3001Alice \u306e\u30e1\u30bd\u30c3\u30c9\u3068\u3057\u3066\u7528\u610f\u3057\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u3088\u306d\u3002<br \/>\n\u5b9f\u306f\u3001\u30e2\u30ce\u3067\u3042\u308b\u9784(Bag)\u306b\u6a5f\u80fd\u3092\u4ed5\u639b\u3051\u3066\u304a\u3044\u3066\u3001\u4eba\u3067\u3042\u308b\u30a2\u30ea\u30b9\u306b\u901a\u77e5\u3059\u308b\u3001\u3063\u3066\u306e\u304c\u3044\u3044\u611f\u3058\u304b\u306a\u3068\u3002\n<\/p>\n<p>\n\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nD:\\work\\blog\\src\\alice&gt;a\nwho use my Prada bag!!!\n<\/pre>\n<p>\n<b>\u8ab0\u304b\u79c1\u306e\u30d0\u30c3\u30b0\u3092\u4f7f\u3063\u305f\u30c3!!!<\/b>\u3063\u3066\u6012\u308a\u307e\u3059\u3002\u30ed\u30ea\u30fc\u30bf\u304b\u3089\u306f Use \u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u8eab\u306f\u898b\u308c\u306a\u3044\u3057\u3001\u305d\u3082\u305d\u3082 Lolita \u306f ICatch \u3092\u7d99\u627f\u3057\u3066\u306a\u3044\u306e\u3067\u30a2\u30e9\u30fc\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u53d7\u3051\u53d6\u308a\u307e\u305b\u3093\u3002\n<\/p>\n<p>\n\u4f3c\u305f\u3088\u3046\u306a\u30d1\u30bf\u30fc\u30f3\u3068\u3057\u3066\u306f\u3001\n<\/p>\n<ul>\n<li>Bag \u30af\u30e9\u30b9\u306e\u30c7\u30b9\u30c8\u30e9\u30af\u30bf\u306b\u4ed5\u8fbc\u3093\u3067\u3001<b>\u306a\u3093\u3067\u3001\u79c1\u306e\u9784\u3092\u6368\u3066\u308b\u306e\u3088\u30c3!!!<\/b>\u3068\u304b\u3002<\/li>\n<li>List<Bag*> \u3092\u6539\u9020\u3057\u3066\u3001<b>\u306a\u3093\u3067\u3001\u79c1\u306e\u9784\u3092\u6301\u3063\u3066\u3044\u308b\u306e\u3088\u30c3!!!<\/b>\u3068\u304b<\/li>\n<\/ul>\n<p>\n\u304c\u3067\u304d\u307e\u3059\u3002\u9784\u3068\u3044\u3046\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u3072\u3068\u3064\u306a\u306e\u3067\u3001Alice::bags \u3068 Lolita::bags \u306e\u4e21\u65b9\u306b\u3042\u308b\u3063\u3066\u306e\u306f\u5999\u306a\u611f\u3058\u3067\u3059\u3088\u306d\u3002\u5b9f\u969b\u306f\u3001\u30dd\u30a4\u30f3\u30bf\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u9784\u305d\u306e\u3082\u306e\u304c\u7f6e\u3044\u3066\u3042\u308b\u3068\u3044\u3046\u3088\u308a\u3082\u3001\u9784\u3092\u793a\u3059\u30bf\u30b0(\u6240\u6709\u6a29)\u3092\u64ae\u308a\u5efb\u3057\u3066\u3044\u308b\u3063\u3066\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u304c\u3002\u9784\u305d\u306e\u3082\u306e\u306f\u5b9f\u4f53\u306a\u306e\u3067\u3072\u3068\u3064\u3057\u304b\u306a\u3044\u3051\u3069\u3001\u30dd\u30a4\u30f3\u30bf(\u6307\u3057\u793a\u3059\u3082\u306e)\u306f\u3001\u3044\u304f\u3089\u3067\u3082\u3067\u304d\u308b\u304b\u3089 list<bag*> \u306e\u3088\u3046\u306b\u30dd\u30a4\u30f3\u30bf\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u5834\u5408\u306f\u3001\u6240\u6709\u81ea\u4f53\u3092\u5236\u9650\u3055\u305b\u308b\u306e\u306f\u3067\u304d\u306a\u3044\u306e\u304b\u306a\u3068\u3002\u5199\u771f\u307f\u305f\u3044\u306a\u3082\u306e\u3067\u3059\u304b\u3089\u3002\u8096\u50cf\u6a29\u3092\u4e3b\u5f35\u3067\u304d\u3066\u3082\u3001\u5bfe\u8c61\u305d\u306e\u3082\u306e\u3092\u5199\u771f\u3067\u5199\u3059\u3053\u3092\u5236\u9650\u3059\u308b\u306e\u306f\u96e3\u3057\u3044\u3001\u3063\u3066\u3044\u3046\u610f\u5473\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6012\u6d9b\u306e\u30a2\u30ea\u30d7\u30e9\u30b7\u30ea\u30fc\u30ba\u3092\u3082\u3046\u3072\u3068\u3064\u3002 \u9784\u306b\u5bfe\u3057\u3066\u30de\u30fc\u30ad\u30f3\u30b0\u3092\u3059\u308b\u306e\u306f\u6d88\u6975\u7684\u306a\u624b\u6bb5\u3067\u3057\u3066\u3001\u30de\u30fc\u30ad\u30f3\u30b0\u3092\u4e0a\u66f8\u304d\u3055\u308c\u3066\u3057\u307e\u3063\u305f\u308a\u3001\u30de\u30fc\u30ad\u30f3\u30b0\u81ea\u4f53\u3092\u7121\u8996\u3057\u3066 Use \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u305f\u308a\u3059\u308b\u3068\u30a2\u30ea\u30b9\u306f\u304a\u624b\u4e0a\u3052\u3067\u3059\u3002\u306a\u306e\u3067\u3001\u3082\u3063 &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/2017\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[22],"tags":[],"class_list":["post-2017","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=2017"}],"version-history":[{"count":1,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2017\/revisions"}],"predecessor-version":[{"id":2022,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2017\/revisions\/2022"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=2017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=2017"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=2017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}