{"id":322789,"date":"2021-02-05T21:55:26","date_gmt":"2021-02-05T13:55:26","guid":{"rendered":"http:\/\/4563.org\/?p=322789"},"modified":"2021-02-05T21:55:26","modified_gmt":"2021-02-05T13:55:26","slug":"%e3%80%8ac-primer%e3%80%8b%e4%b8%adargument-passing%e7%ab%a0%e8%8a%82%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=322789","title":{"rendered":"\u300aC++ Primer\u300b\u4e2d\u201cArgument Passing\u201d\u7ae0\u8282\u603b\u7ed3"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u300aC++ Primer\u300b\u4e2d\u201cArgument Passing\u201d\u7ae0\u8282\u603b\u7ed3               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : XIVN1987 <\/span>  <span><i><\/i> 8<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4e0b\u9762\u662f\u6211\u9605\u8bfb\u300a C++ Primer \u300b\u4e2d\u201cArgument Passing\u201d\u7ae0\u8282\u505a\u7684\u4e00\u4e2a\u5c0f\u7ed3\uff0c\uff0c\u5927\u5bb6\u770b\u770b\u6709\u6ca1\u6709\u9519\u8bef<\/p>\n<h2>\u53c2\u6570<\/h2>\n<h3>passed by value<\/h3>\n<p>the value of the argument is copied to the parameter, nothing the function does to the parameter can affect the argument<\/p>\n<h3>passed by pointer<\/h3>\n<p>behave like <code>passed by value<\/code>, the value of the argument pointer is copied to the parameter pointer, the two pointers are distinct. However, a pointer also gives us indirect access to the object to which that pointer points.<\/p>\n<p>\u4fee\u6539 argument pointer \u672c\u8eab\u4e0d\u4f1a\u5f71\u54cd parameter pointer\uff0c\u4f46\u901a\u8fc7 argument pointer \u4fee\u6539\u5b83\u6307\u5411\u7684\u5bf9\u8c61\uff0c\u4f1a\u540c\u6837\u4fee\u6539 parameter pointer \u6307\u5411\u7684\u5bf9\u8c61\uff0c\u56e0\u4e3a\u5b83\u4eec\u6307\u5411\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002<\/p>\n<h3>passed by reference<\/h3>\n<p>operations on a reference are actually operations on the object to which the reference refers, often used to allow a function to change the value of its arguments<\/p>\n<p>\u5f15\u7528\u4f20\u53c2\u6709\u4e24\u4e2a\u4f5c\u7528\uff1a<\/p>\n<ul>\n<li>\u907f\u514d\u62f7\u8d1d<\/li>\n<li>\u4fee\u6539\u88ab\u5f15\u7528\u5bf9\u8c61\u7684\u503c\uff0c\u5b9e\u73b0\u591a\u8fd4\u56de\u503c\u6548\u679c<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e\u539f\u59cb\u7c7b\u578b\u53c2\u6570\uff0c\u62f7\u8d1d\u4ee3\u4ef7\u5f88\u5c0f\uff0c\u53ea\u6709\u5f53\u9700\u8981\u5229\u7528\u5b83\u8fd4\u56de\u989d\u5916\u4fe1\u606f\u65f6\u624d\u9700\u8981\u5f15\u7528\u4f20\u53c2<\/p>\n<p>\u5bf9\u4e8e\u590d\u5408\u7c7b\u578b\u53c2\u6570\uff0c\u5f15\u7528\u4f20\u53c2\u4e00\u822c\u662f\u4e3a\u4e86\u907f\u514d\u62f7\u8d1d\uff0c\u4e0d\u4f1a\u5728\u51fd\u6570\u5185\u90e8\u7ed9\u5b83\u91cd\u65b0\u8d4b\u503c\uff0c\u56e0\u6b64\u4e00\u822c\u4f1a\u7528<code>const<\/code>\u4fee\u9970<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5047837\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : auto8888 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e2a\u77e5\u8bc6\u70b9\u8fd8\u662f\u76f8\u5bf9\u7b80\u5355\u7684<\/p>\n<p>\u51fd\u6570\u53c2\u6570 \u57fa\u672c\u7c7b\u578b\u53ef\u4ee5\u76f4\u63a5\u4f20\u503c<\/p>\n<p>\u7b26\u5408\u7c7b\u578b\u4f20\u5e38\u5f15\u7528\uff0c\u8fd8\u80fd\u907f\u514d\u65e0\u610f\u66f4\u6539<\/p>\n<p>\u9700\u8981\u66f4\u6539\u53c2\u6570\u503c\u5c31\u4f20\u5f15\u7528<\/p>\n<p>\u5f15\u7528\u662f c++\u624d\u6709\u7684\uff0cC \u6ca1\u6709                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u300aC++ Primer\u300b\u4e2d\u201cArg&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/322789"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322789"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/322789\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322789"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}