{"id":411,"date":"2010-04-20T20:43:59","date_gmt":"2010-04-20T12:43:59","guid":{"rendered":"http:\/\/115.29.108.60\/?p=411"},"modified":"2010-10-03T18:51:07","modified_gmt":"2010-10-03T10:51:07","slug":"c-primer-chapter6","status":"publish","type":"post","link":"http:\/\/115.29.108.60\/?p=411","title":{"rendered":"C++ Primer Chapter6"},"content":{"rendered":"<p>1\u3001switch\u8868\u8fbe\u5f0f\u5fc5\u987b\u4ea7\u751f\u4e00\u4e2a\u6574\u6570\u7ed3\u679c\uff0ccase\u6807\u53f7\u5fc5\u987b\u662f\u6574\u578b\u5e38\u91cf\u8868\u8fbe\u5f0f\u3002\u5982\u679c\u4e24\u4e2acase\u6807\u53f7\u5177\u6709\u76f8\u540c\u7684\u503c\uff0c\u540c\u6837\u4e5f\u4f1a\u5bfc\u81f4\u7f16\u8bd1\u65f6\u7684\u9519\u8bef\u3002<\/p>\n<p>case 3.14:\u00a0\u00a0\u00a0 \/\/ \u4e0d\u662f\u6574\u578b<\/p>\n<p>case iVal:\u00a0\u00a0\u00a0 \/\/ \u4e0d\u662f\u5e38\u91cf<\/p>\n<p>2\u3001\u5bf9\u4e8eswitch\u7ed3\u6784\uff0c\u53ea\u80fd\u5728\u5b83\u7684\u6700\u540e\u4e00\u4e2acase\u6807\u53f7\u6216default\u6807\u53f7\u540e\u9762\u5b9a\u4e49\u53d8\u91cf\u3002\u5236\u5b9a\u8fd9\u4e2a\u89c4\u5219\u662f\u4e3a\u4e86\u907f\u514d\u51fa\u73b0\u4ee3\u7801\u8df3\u8fc7\u53d8\u91cf\u7684\u5b9a\u4e49\u548c\u521d\u59cb\u5316\u7684\u60c5\u51b5\u3002<\/p>\n<p>3\u3001\u5728\u5faa\u73af\u6761\u4ef6\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\u5728\u6bcf\u6b21\u5faa\u73af\u91cc\u90fd\u8981\u7ecf\u5386\u521b\u5efa\u548c\u64a4\u9500\u7684\u8fc7\u7a0b\u3002<\/p>\n<p>4\u3001\u53ef\u4ee5\u5728for\u8bed\u53e5\u7684init-statement\u4e2d\u5b9a\u4e49\u591a\u4e2a\u5bf9\u8c61\uff1b\u4f46\u662f\u4e0d\u7ba1\u600e\u4e48\u6837\uff0c\u8be5\u5904\u53ea\u80fd\u51fa\u73b0\u4e00\u4e2a\u8bed\u53e5\uff0c\u56e0\u6b64\u6240\u6709\u7684\u5bf9\u8c61\u5fc5\u987b\u5177\u6709\u76f8\u540c\u7684\u4e00\u822c\u7c7b\u578b\u3002<\/p>\n<p>5\u3001goto\u8bed\u53e5\u4e0d\u80fd\u8de8\u8d8a\u53d8\u91cf\u7684\u5b9a\u4e49\u8bed\u53e5\u5411\u524d\u8df3\u8f6c\uff1b\u5982\u679c\u786e\u5b9e\u9700\u8981\u5728goto\u548c\u5176\u8df3\u8f6c\u5bf9\u5e94\u7684\u6807\u53f7\u4e4b\u95f4\u5b9a\u4e49\u53d8\u91cf\uff0c\u5219\u5b9a\u4e49\u5fc5\u987b\u653e\u5728\u4e00\u4e2a\u5757\u8bed\u53e5\u4e2d\u3002<\/p>\n<p>6\u3001\u4e0e\u5176\u4ed6\u5757\u8bed\u53e5\u4e00\u6837\uff0ctry\u5757\u5f15\u5165\u5c40\u90e8\u4f5c\u7528\u57df\uff0c\u5728try\u5757\u4e2d\u58f0\u660e\u7684\u53d8\u91cf\uff0c\u5305\u62eccatch\u5b50\u53e5\u4e2d\u58f0\u660e\u7684\u53d8\u91cf\uff0c\u4e0d\u80fd\u5728try\u5916\u9762\u5f15\u7528\u3002<\/p>\n<p>7\u3001\u53ef\u4f7f\u7528NDEBUG\u9884\u5904\u7406\u53d8\u91cf\u5b9e\u73b0\u6709\u6761\u4ef6\u7684\u8c03\u8bd5\u4ee3\u7801\uff1a<\/p>\n<p>#ifndef NDEBUG<\/p>\n<p>\/\/ Error<\/p>\n<p>#endif<\/p>\n<p>8\u3001\u9884\u5904\u7406\u5668\u8fd8\u5b9a\u4e49\u4e86\u5176\u4f59\u56db\u79cd\u5728\u8c03\u8bd5\u65f6\u975e\u5e38\u6709\u7528\u7684\u5e38\u91cf\uff1a<\/p>\n<p>__FILE__\u00a0\u00a0\u00a0 \/\/ \u6587\u4ef6\u540d<\/p>\n<p>__LINE__\u00a0\u00a0\u00a0 \/\/ \u5f53\u524d\u884c\u53f7<\/p>\n<p>__DATE__\u00a0\u00a0\u00a0 \/\/ \u6587\u4ef6\u88ab\u7f16\u8bd1\u7684\u65e5\u671f<\/p>\n<p>__TIME__\u00a0\u00a0\u00a0 \/\/ \u6587\u4ef6\u88ab\u7f16\u8bd1\u7684\u65f6\u95f4<\/p>\n<p>9\u3001\u4e0e\u5f02\u5e38\u4e0d\u540c\uff08\u5f02\u5e38\u7528\u4e8e\u5904\u7406\u7a0b\u5e8f\u6267\u884c\u65f6\u9884\u671f\u8981\u53d1\u751f\u7684\u9519\u8bef\uff09\uff0c\u7a0b\u5e8f\u5458\u4f7f\u7528assert\u6765\u6d4b\u8bd5\u201c\u4e0d\u53ef\u80fd\u53d1\u751f\u201d\u7684\u6761\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001switch\u8868\u8fbe\u5f0f\u5fc5\u987b\u4ea7\u751f\u4e00\u4e2a\u6574\u6570\u7ed3\u679c\uff0ccase\u6807\u53f7\u5fc5\u987b\u662f\u6574\u578b\u5e38\u91cf\u8868\u8fbe\u5f0f\u3002\u5982\u679c\u4e24\u4e2acase\u6807\u53f7\u5177\u6709\u76f8\u540c\u7684\u503c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-411","post","type-post","status-publish","format-standard","hentry","category-cplusplusprimer"],"_links":{"self":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=411"}],"version-history":[{"count":4,"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts\/411\/revisions"}],"predecessor-version":[{"id":542,"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts\/411\/revisions\/542"}],"wp:attachment":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}