{"id":669,"date":"2009-06-18T11:39:56","date_gmt":"2009-06-18T02:39:56","guid":{"rendered":"http:\/\/www.gesource.jp\/weblog\/?p=669"},"modified":"2017-07-16T20:52:28","modified_gmt":"2017-07-16T11:52:28","slug":"__property","status":"publish","type":"post","link":"https:\/\/www.gesource.jp\/weblog\/?p=669","title":{"rendered":"__property\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"<p>__property\u306e\u4f7f\u3044\u65b9\u3092\u6574\u7406\u3057\u3066\u307f\u305f\u3002<\/p>\n<p>\u57fa\u672c\u5f62<\/p>\n<pre><code>__property \u578b \u540d\u524d = { \u30d7\u30ed\u30d1\u30c6\u30a3\u5c5e\u6027 = \u30c7\u30fc\u30bf\/\u95a2\u6570, \u2026 }\n<\/code><\/pre>\n<p>\u30d7\u30ed\u30d1\u30c6\u30a3\u5c5e\u6027\u306e\u7a2e\u985e<\/p>\n<ul>\n<li>read<br \/>\n\u8aad\u307f\u8fbc\u307f\u6642\u306b\u53c2\u7167\u3059\u308b\u5909\u6570\/\u95a2\u6570<\/p>\n<\/li>\n<li>\n<p>write<br \/>\n\u66f8\u304d\u8fbc\u307f\u6642\u306b\u53c2\u7167\u3059\u308b\u5909\u6570\/\u95a2\u6570<\/p>\n<\/li>\n<li>\n<p>stored<br \/>\nture\/false\/\u8ad6\u7406\u5024\u3092\u8fd4\u3059\u95a2\u6570<br \/>\n\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u3057\u3066\u4fdd\u5b58\u3059\u308b\u304b\u3069\u3046\u304b<\/p>\n<\/li>\n<li>\n<p>default<br \/>\n\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u5024<\/p>\n<\/li>\n<li>\n<p>nodefault<\/p>\n<\/li>\n<li>\n<p>index<br \/>\n\u30ea\u30b9\u30c8\u3084\u914d\u5217\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4f8b\uff1a\u30e1\u30f3\u30d0\u5909\u6570\u3092\u76f4\u63a5\u8aad\u307f\u66f8\u304d<\/p>\n<pre><code>class TMyClass {\nprivate:\n  int FCount;\npublic:\n  TMyClass() : FCount(0) {};\n  __property int Count = { read = FCount, write=FCount }; \/\/\u30e1\u30f3\u30d0\u5909\u6570\u3092\u6307\u5b9a\n};\n\nTMyClass obj;\nobj.Count = 123;\ncout &lt;&lt; obj.Count &lt;&lt; endl; \/\/=&gt;123\n<\/code><\/pre>\n<p>\u4f8b\uff1a\u30e1\u30f3\u30d0\u95a2\u6570\u3092\u901a\u3057\u3066\u8aad\u307f\u66f8\u304d<\/p>\n<pre><code>class TMyClass {\nprivate:\n  int FCount;\n  void SetCount(int Count);\n  int GetCount();\npublic:\n  TMyClass() : FCount(0) {};\n  __property int Count = { read = GetCount, write=SetCount }; \/\/\u30e1\u30f3\u30d0\u95a2\u6570\u3092\u6307\u5b9a\n};\n<\/code><\/pre>\n<p>\u4f8b\uff1a\u8aad\u307f\u8fbc\u307f\u5c02\u7528<\/p>\n<pre><code>class TMyClass {\nprivate:\n  int FCount;\npublic:\n  TMyClass() : FCount(0) {};\n  __property int Count = { read = FCount }; \/\/read\u306e\u307f\n};\n<\/code><\/pre>\n<p>\u4f8b\uff1a\u66f8\u304d\u8fbc\u307f\u5c02\u7528<\/p>\n<pre><code>class TMyClass {\nprivate:\n  int FCount;\npublic:\n  TMyClass() : FCount(0) {};\n  __property int Count = { write=FCount }; \/\/write\u306e\u307f\n};\n<\/code><\/pre>\n<p>\u4f8b\uff1a\u9759\u7684\u30d7\u30ed\u30d1\u30c6\u30a3<\/p>\n<pre><code>class TMyClass {\npublic:\n  static int FCount;\n  static int GetCount();\n  static void SetCount(int Count);\n  __property int Count = { read = GetCount, write = SetCount }; \/\/\u9759\u7684\u30d7\u30ed\u30d1\u30c6\u30a3\n};\n\ncout &lt;&lt; TMyClass::Count &lt;&lt; endl;\n<\/code><\/pre>\n<p>\u4f8b\uff1a\u914d\u5217<\/p>\n<pre><code>class TMyClass {\nprivate:\n  int FDate[3];\n  int GetDate(int Index) { return FDate[Index]; }\npublic:\n  TMyClass() { FDate[0] = 2009; FDate[1] = 1; FDate[2] = 2; };\n  __property int Year = { read=GetDate, index = 0 };\n  __property int Month = { read=GetDate, index = 1 };\n  __property int Day = { read=GetDate, index = 2 };\n};\n\nTMyClass obj;\ncout &lt;&lt; obj.Year &lt;&lt; endl; \/\/=&gt; 2009\ncout &lt;&lt; obj.Month &lt;&lt; endl; \/\/=&gt; 1\ncout &lt;&lt; obj.Day &lt;&lt; endl; \/\/=&gt; 2\n<\/code><\/pre>\n<p>\u4f8b\uff1a\u30ea\u30b9\u30c8<\/p>\n<pre><code>class TMyClass {\nprivate:\n  unique_ptr&lt;TStringList&gt; FDate;\n  UnicodeString GetDate(int Index) { return FDate-&gt;Strings[Index]; }\npublic:\n  TMyClass() : FDate(new TStringList()) {\n    FDate-&gt;Add(\"2009\"); FDate-&gt;Add(\"1\"); FDate-&gt;Add(\"2\");\n  };\n  __property UnicodeString Year = { read=GetDate, index = 0 };\n  __property UnicodeString Month = { read=GetDate, index = 1 };\n  __property UnicodeString Day = { read=GetDate, index = 2 };\n};\n\nTMyClass obj;\nwcout &lt;&lt; obj.Year.c_str() &lt;&lt; endl; \/\/=&gt; 2009\nwcout &lt;&lt; obj.Month.c_str() &lt;&lt; endl; \/\/=&gt; 1\nwcout &lt;&lt; obj.Day.c_str() &lt;&lt; endl; \/\/=&gt; 2\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>__property\u306e\u4f7f\u3044\u65b9\u3092\u6574\u7406\u3057\u3066\u307f\u305f\u3002 \u57fa\u672c\u5f62 __property \u578b \u540d\u524d = { \u30d7\u30ed\u30d1\u30c6\u30a3\u5c5e\u6027 = \u30c7\u30fc\u30bf\/\u95a2\u6570, \u2026 } \u30d7\u30ed\u30d1\u30c6\u30a3\u5c5e\u6027\u306e\u7a2e\u985e read \u8aad\u307f\u8fbc\u307f\u6642\u306b\u53c2\u7167\u3059\u308b\u5909\u6570\/\u95a2\u6570 write \u66f8\u304d\u8fbc &#8230;<\/p>\n<p><a href=\"https:\/\/www.gesource.jp\/weblog\/?p=669\" class=\"more-link\">Continue reading &lsquo;__property\u306e\u4f7f\u3044\u65b9&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16],"tags":[149],"class_list":["post-669","post","type-post","status-publish","format-standard","hentry","category-cbuilder","tag-cbuilder"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=669"}],"version-history":[{"count":0,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/669\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}