{"id":7470,"date":"2024-04-03T10:01:01","date_gmt":"2024-04-03T02:01:01","guid":{"rendered":""},"modified":"2024-04-03T10:01:01","modified_gmt":"2024-04-03T02:01:01","slug":"\u3010\u8f6c\u3011C\u8bed\u8a00\u4e2d -\uff1e \u662f\u4ec0\u4e48\u610f\u601d\uff1f","status":"publish","type":"post","link":"https:\/\/mushiming.com\/7470.html","title":{"rendered":"\u3010\u8f6c\u3011C\u8bed\u8a00\u4e2d -\uff1e \u662f\u4ec0\u4e48\u610f\u601d\uff1f"},"content":{"rendered":"

 ->\u662f\u4e00\u4e2a\u6574\u4f53\uff0c\u5b83\u662f\u7528\u4e8e\u6307\u5411\u7ed3\u6784\u4f53\u3001C++\u4e2d\u7684class\u7b49\u542b\u6709\u5b50\u6570\u636e\u7684\u6307\u9488\u7528\u6765\u53d6\u5b50\u6570\u636e\u3002\u6362\u79cd\u8bf4\u6cd5\uff0c\u5982\u679c\u6211\u4eec\u5728C\u8bed\u8a00\u4e2d\u5b9a\u4e49\u4e86\u4e00\u4e2a\u7ed3\u6784\u4f53\uff0c\u7136\u540e\u7533\u660e\u4e00\u4e2a\u6307\u9488\u6307\u5411\u8fd9\u4e2a\u7ed3\u6784\u4f53\uff0c\u90a3\u4e48\u6211\u4eec\u8981\u7528\u6307\u9488\u53d6\u51fa\u7ed3\u6784\u4f53\u4e2d\u7684\u6570\u636e\uff0c\u5c31\u8981\u7528\u5230\u201c->\u201d.<\/code><\/p>\n

\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/strong>\nstruct Data\n{\n   int a,b,c;\n};              \/*\u5b9a\u4e49\u7ed3\u6784\u4f53*\/\nstruct Data * p;\/*\u5b9a\u4e49\u7ed3\u6784\u4f53\u6307\u9488*\/\nstruct Data A = {1,2,3};\/*\u58f0\u660e\u53d8\u91cfA*\/\nint x;\/*\u58f0\u660e\u4e00\u4e2a\u53d8\u91cfx*\/\np = &A ; \/*\u8ba9p\u6307\u5411A*\/\nx = p->a;\/*\u8fd9\u53e5\u8bdd\u7684\u610f\u601d\u5c31\u662f\u53d6\u51fap\u6240\u6307\u5411\u7684\u7ed3\u6784\u4f53\u4e2d\u5305\u542b\u7684\u6570\u636e\u9879a\u8d4b\u503c\u7ed9x*\/\n         \/*\u7531\u4e8e\u6b64\u65f6p\u6307\u5411A\uff0c\u56e0\u800c p->a == A.a,\u4e5f\u5c31\u662f1*\/\n\n\u5bf9\u4e8e\u4e00\u5f00\u59cb\u7684\u95ee\u9898 p = p->next;\u8fd9\u5e94\u8be5\u51fa\u73b0\u5728C\u8bed\u8a00\u7684\u94fe\u8868\uff0c\u8fd9\u91cc\u7684next\u5e94\u8be5\u662f\u4e00\u4e2a\u4e0ep\u540c\u7c7b\u578b\u7684\u7ed3\u6784\u4f53\u6307\u9488\uff0c\u5176\u5b9a\u4e49\u683c\u5f0f\u5e94\u8be5\u662f\uff1a\nstruct Data \n{\n   int a;\n   struct Data * next;\n};\/*\u5b9a\u4e49\u7ed3\u6784\u4f53*\/\n\u2026\u2026\u2026\u2026\nmain()\n{\n   struct Data * p;\/*\u58f0\u660e\u6307\u9488\u53d8\u91cfp*\/\n  \u2026\u2026\n   p = p->next;\/*\u5c06next\u4e2d\u7684\u503c\u8d4b\u7ed9p*\/\n}\n\n\n    \u94fe\u8868\u6307\u9488\u662fC\u8bed\u8a00\u7684\u4e00\u4e2a\u96be\u70b9\uff0c\u4f46\u4e5f\u662f\u91cd\u70b9\uff0c\u5b66\u61c2\u4e86\u975e\u5e38\u6709\u7528\u3002\u8981\u4ed4\u7ec6\u8bb2\u5c31\u5fc5\u987b\u5148\u8bb2\u53d8\u91cf\u3001\u6307\u9488\u3002\n\n    \u4ec0\u4e48\u662f\u53d8\u91cf\uff1f\u6240\u8c13\u53d8\u91cf\uff0c\u4e0d\u8981\u6d45\u663e\u7684\u8ba4\u4e3a\u4f1a\u53d8\u5f97\u91cf\u5c31\u662f\u53d8\u91cf\u3002\u5957\u7528\u6211\u4eec\u9662\u957f\u7684\u95ee\u8bdd\uff1a\u201c\u6559\u5ba4\u53d8\u4e0d\u53d8\uff1f\u201d\u53d8\uff0c\u56e0\u4e3a\u6bcf\u5929\u6709\u4e0d\u540c\u7684\u4eba\u5728\u91cc\u9762\u4e0a\u8bfe\uff0c\u4f46\u53c8\u4e0d\u53d8\uff0c\u56e0\u4e3a\u6559\u5ba4\u59cb\u7ec8\u5728\u90a3\uff0c\u6ca1\u6709\u53d8\u5927\u6216\u53d8\u5c0f\u3002\u8fd9\u5c31\u662f\u53d8\u91cf\uff1a\u6709\u4e00\u4e2a\u4e0d\u53d8\u7684\u5730\u5740\u548c\u4e00\u5757\u53ef\u53d8\u7684\u5b58\u50a8\u7a7a\u95f4\u3002\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ea\u770b\u5230\u53d8\u91cf\u8fd9\u4e2a\u623f\u95f4\u91cc\u9762\u7684\u4e1c\u897f\uff0c\u4e5f\u5c31\u662f\u5176\u5185\u5bb9\uff0c\u4f46\u4e0d\u4f1a\u5173\u6ce8\u53d8\u91cf\u7684\u5730\u5740\uff0c\u4f46\u662fC\u8bed\u8a00\u7684\u6307\u9488\uff0c\u5c31\u662f\u8fd9\u4e2a\u623f\u95f4\u7684\u5730\u5740\u3002\u6211\u4eec\u58f0\u660e\u53d8\u91cf\u5c31\u76f8\u5f53\u4e8e\u76d6\u4e86\u95f4\u623f\u5b50\u5b58\u653e\u4e1c\u897f\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u89c2\u770b\u623f\u5b50\u91cc\u7684\u4e1c\u897f\uff0c\u800c\u58f0\u660e\u6307\u9488\uff0c\u5c31\u662f\u76f8\u5f53\u4e8e\u83b7\u5f97\u4e86\u4e00\u4e2a\u5b9a\u4f4d\u5668\uff0c\u5f53\u7528\u6307\u9488\u6307\u5411\u67d0\u4e2a\u53d8\u91cf\u65f6\uff0c\u5c31\u662f\u7528\u6307\u9488\u7ed9\u53d8\u91cf\u5b9a\u4f4d\uff0c\u4ee5\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u7528\u6307\u9488\u627e\u5230\u4ed6\u6240\u201c\u8ddf\u8e2a\u201d\u7684\u53d8\u91cf\u5e76\u53ef\u4ee5\u83b7\u5f97\u91cc\u9762\u7684\u5185\u5bb9\u3002\n\u90a3\u7ed3\u6784\u4f53\u5462\uff1f\u7ed3\u6784\u4f53\u5c31\u76f8\u5f53\u4e8e\u662f\u6709\u597d\u51e0\u4e2a\u623f\u5b50\u7ec4\u6210\u7684\u522b\u5885\uff0c\u51e0\u4e2a\u623f\u5b50\u7ed1\u5b9a\u5728\u4e00\u8d77\u4f7f\u7528\u3002\u5047\u8bbe\u73b0\u5728\u6709\u5f88\u591a\u8fd9\u79cd\u522b\u5885\u5206\u5e03\u5728\u4e00\u4e2a\u5927\u8ff7\u5bab\u91cc\uff0c\u6bcf\u95f4\u522b\u5885\u91cc\u90fd\u6709\u4e00\u95f4\u623f\u5b50\u3002\u91cc\u9762\u653e\u4e86\u53e6\u4e00\u4e2a\u522b\u5885\u7684\u4f4d\u7f6e\u4fe1\u606f\uff0c\u73b0\u5728\u4f60\u624b\u62ff\u5b9a\u4f4d\u5668\u627e\u5230\u4e86\u7b2c\u4e00\u680b\u522b\u5885\uff0c\u4ece\u91cc\u9762\u5f97\u5230\u4e86\u4f60\u60f3\u8981\u7684\u4e1c\u897f\uff08\u94fe\u8868\u7684\u6570\u636e\u90e8\u5206\uff09,\u7136\u540e\u628a\u4e0b\u4e00\u680b\u522b\u5885\u7684\u4f4d\u7f6e\u8ba1\u5165\u4f60\u7684\u5b9a\u4f4d\u5668\uff08p = p->next\uff09\uff0c\u518d\u8d70\u5411\u4e0b\u4e00\u680b\u522b\u5885\u2026\u2026\u5982\u6b64\u8d70\u4e0b\u53bb\uff0c\u77e5\u9053\u8d70\u5230\u67d0\u5730\u4e0b\u4e00\u680b\u522b\u5885\u4fe1\u606f\u6ca1\u6709\u4e86\uff08p->next == NULL\uff09\uff0c\u4f60\u7684\u65c5\u884c\u7ed3\u675f\u3002\u8fd9\u5c31\u662f\u94fe\u8868\u4e00\u6b21\u904d\u5386\u7684\u8fc7\u7a0b\u3002\u73b0\u5728\u4f60\u80fd\u660e\u767d p=p->next\u7684\u542b\u4e49\u4e86\u5427\uff01\n\u5199\u4e86\u8fd9\u4e48\u591a\u3002\u5e0c\u671b\u4f60\u80fd\u660e\u767d\u3002\n\n    \u5982\u679c\u60f3\u5b66\u597dc\u548cC++\uff0c\u94fe\u8868\u548c\u6307\u9488\u5fc5\u987b\u719f\u7ec3\u638c\u63e1\uff01<\/pre>\n","protected":false},"excerpt":{"rendered":"\u3010\u8f6c\u3011C\u8bed\u8a00\u4e2d -\uff1e \u662f\u4ec0\u4e48\u610f\u601d\uff1f->\u662f\u4e00\u4e2a\u6574\u4f53\uff0c\u5b83\u662f\u7528\u4e8e\u6307\u5411\u7ed3\u6784\u4f53\u3001C++\u4e2d\u7684class\u7b49\u542b\u6709\u5b50\u6570\u636e\u7684\u6307\u9488\u7528\u6765\u53d6\u5b50\u6570\u636e","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7470"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=7470"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7470\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=7470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=7470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=7470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}