{"id":19969,"date":"2015-09-14T16:15:00","date_gmt":"2015-09-14T07:15:00","guid":{"rendered":"http:\/\/www.tyosuke20xx.com\/blog\/?p=19969"},"modified":"2015-09-14T16:15:00","modified_gmt":"2015-09-14T07:15:00","slug":"c%e3%80%80%e5%88%97%e6%8c%99%e5%9e%8b","status":"publish","type":"post","link":"http:\/\/www.tyosuke20xx.com\/blog\/?p=19969","title":{"rendered":"C++\u3000\u5217\u6319\u578b"},"content":{"rendered":"<p>#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>\/\/\u5217\u6319\u578b<br \/>\nenum WEAPON_TYPE<br \/>\n{<br \/>\n<span style=\"white-space: pre;\"> <\/span>LargeS<br \/>\n<span style=\"white-space: pre;\"> <\/span>HeavyyBowgun<br \/>\n};<\/p>\n<p>struct HUNTER<br \/>\n{<br \/>\n<span style=\"white-space: pre;\"> <\/span>int money;<br \/>\n<span style=\"white-space: pre;\"> <\/span>int rank;<br \/>\n<span style=\"white-space: pre;\"> <\/span>char name[32];<br \/>\n};<\/p>\n<p>int main()<br \/>\n{<br \/>\n<span style=\"white-space: pre;\"> <\/span>\/\/int\u578b\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(int) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/unsigned short\u578b\u306e\u30b5\u30a4\u30ba(\u3070\u3044\u3068\u6570)\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(unsigned short) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/double\u578b\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(double) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/HUNTER\u578b\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(HUNTER) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/\u5909\u6570d\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>double d;<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(d) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/\u914d\u5217a\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>int a[3];<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(a) &lt;&lt; endl;<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(a[0]) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/\u69cb\u9020\u4f53\u5185\u90e8\u306e\u30e1\u30f3\u30d0\u5909\u6570\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(HUNTER::name) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/\u6587\u5b57\u5217&#8221;Hello&#8221;\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(&#8220;Hello&#8221;) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/\u6587\u5b57\u5217&#8221;Hello&#8221;\u304c\u683c\u7d0d\u3055\u308c\u305f\u914d\u5217text\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>char text[32] = &#8220;hello&#8221;;<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(text) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/\u95a2\u6570main\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(1 + 1) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/\u6574\u6570\u5024(int) + \u5c0f\u6570double\u578b = (\u5c0f\u6570(double)<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(1 + 1.0) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/\u5217\u6319\u578b\u306e\u30b5\u30a4\u30ba\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(WEAPON_TYPE) &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/char\u578b\u306e\u5909\u6570\u306e\u5024\u306e\u7bc4\u56f2\u306f\u3000-128 +127<br \/>\n<span style=\"white-space: pre;\"> <\/span>char c;<br \/>\n<span style=\"white-space: pre;\"> <\/span>c = 129;<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; (int)c &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>short s;<br \/>\n<span style=\"white-space: pre;\"> <\/span>s = 32768;<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; s &lt;&lt; endl;<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>\/\/64bit\u6574\u6570\u578b<br \/>\n<span style=\"white-space: pre;\"> <\/span>__int64 i;<br \/>\n<span style=\"white-space: pre;\"> <\/span>cout &lt;&lt; sizeof(i) &lt;&lt; endl;<br \/>\n<span style=\"white-space: pre;\"> <\/span>return 0;<br \/>\n}<br \/>\n\/\/\u30c0\u30e1\u30fc\u30b8\u8a08\u7b97\u95a2\u6570<br \/>\nint damage(\u653b\u6483\u8005\u306e\u60c5\u5831\u3000\u5bfe\u8c61\u8005\u306e\u60c5\u5831)<br \/>\n{<br \/>\n<span style=\"white-space: pre;\"> <\/span>return \u30c0\u30e1\u30fc\u30b8<br \/>\n}<\/p>\n<p>Itemtype DropItem(\u5012\u3057\u305f\u6575\u306e\u60c5\u5831)<\/p>\n<p>{<\/p>\n<p><span style=\"white-space: pre;\"> <\/span>switch (\u5012\u3057\u305f\u6575 DropID)<br \/>\n<span style=\"white-space: pre;\"> <\/span>{<br \/>\n<span style=\"white-space: pre;\">  <\/span>case 0;<br \/>\n<span style=\"white-space: pre;\">   <\/span>return<br \/>\n<span style=\"white-space: pre;\"> <\/span>}<br \/>\n<span style=\"white-space: pre;\"> <\/span>return Itemtype::<br \/>\n}<br \/>\n\u623b\u308a\u306e\u578b\u3000\u95a2\u6570\u540d(\u5f15\u6570\u306e\u578b \u5f15\u6570\u540d\u3000\u5f15\u6570\u540d\u3001\u30fb\u30fb\u30fb)<br \/>\n{<br \/>\n<span style=\"white-space: pre;\"> <\/span>\u3053\u3053\u3067\u4f55\u304b\u306e\u51e6\u7406<\/p>\n<p><span style=\"white-space: pre;\">  <\/span>return \u7d50\u679c;<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;iostream&gt; using namespace std; \/\/\u5217\u6319\u578b enum WEAPON_TYPE { LargeS HeavyyBowgun }; struct HUNTER { &hellip; <a href=\"http:\/\/www.tyosuke20xx.com\/blog\/?p=19969\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C++\u3000\u5217\u6319\u578b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-19969","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/19969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19969"}],"version-history":[{"count":0,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/19969\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19969"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}