{"id":218,"date":"2026-10-28T17:52:48","date_gmt":"2026-10-28T09:52:48","guid":{"rendered":"https:\/\/xgang-the-reboot.top\/?p=218"},"modified":"2026-10-28T17:55:12","modified_gmt":"2026-10-28T09:55:12","slug":"c-cpp-study","status":"publish","type":"post","link":"https:\/\/xgang-the-reboot.top\/index.php\/notes\/c-cpp-study\/","title":{"rendered":"C\/C++ \u5b66\u4e60\u6742\u8bb0"},"content":{"rendered":"\n<h1 id=\"point\" class=\"wp-block-heading\">\u6307\u9488<\/h1>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8be5\u90e8\u5206\u5185\u5bb9\u6bd4\u8f83\u6d89\u53ca\u786c\u4ef6\u5e95\u5c42\uff0c\u5f88\u53ef\u80fd\u5728\u4e0d\u540c\u7684\u7cfb\u7edf\u90fd\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u6709\u5fc5\u8981\u8d34\u4e00\u4e0b\u6211\u7684\u6838\u5fc3\u914d\u7f6e\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OS : ManjaroLinux &#8211; Kernel6.18<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f16\u8bd1\u5668 \uff1a gcc &#8211; 16.2.1 20260810 (GCC) || \u4f7f\u7528\u4e86 Cmake \u6784\u5efa <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5904\u7406\u5668\u67b6\u6784 : X86_64<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u6982\u5ff5 <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf4\u767d\u4e86\u5c31\u662f\u67d0\u4e00\u4e2a<strong>\u53d8\u91cf\u5bf9\u5e94\u7684\u5185\u5b58\u5730\u5740<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u627e\u4eba\u7528\u7684\uff0c\u53ef\u4ee5\u62bd\u8c61\u6210\u4e00\u4e2a\u4eba\u548c\u4ed6\u6240\u5904\u7684\u4f4d\u7f6e\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u9ed8\u8ba4\u662f\u5341\u516d\u8fdb\u5236\u683c\u5f0f\uff0c\u663e\u793a\u53d8\u91cf\u6240\u5360\u7528\u8fde\u7eed\u5185\u5b58\u7684\u7b2c\u4e00\u4e2a\u5b57\u8282\u5bf9\u5e94\u7684\u5185\u5b58\u5730\u5740\u3002\u6240\u4ee5\u5f88\u5bb9\u6613\u5c31\u80fd\u60f3\u5230\uff0c\u65e2\u7136\u6307\u9488\u8868\u793a\u7684\u662f\u4e00\u4e2a\u53d8\u91cf\u7684\u5185\u5b58\u5730\u5740\uff0c\u90a3\u4e48\u9996\u5148\u7684\u5927\u524d\u63d0\u5c31\u4e00\u5b9a\u662f\u8fd9\u4e2a\u53d8\u91cf\u5f97\u5b58\u5728\u3002\u5b9a\u4e49\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-b-392-f-0-color has-text-color has-875-rem-font-size\"><code>using namespace std ;\n\/\/\u57fa\u672c\u5b9a\u4e49\u516c\u5f0f\n&lt;type> var = &lt;value>\n&lt;type> *ptr = &amp;&lt;Var> ;\n\/\/\u53d8\u91cf\u7c7b\u578b *\u53d8\u91cf\u540d = &amp;\u5176\u4ed6\u53d8\u91cf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636e\u6211\u7684\u7406\u89e3\uff0c\u6211\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u56fe\u7ed9\u5927\u5bb6\u5448\u73b0\u51fa\u6765\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"883\" height=\"1024\" src=\"https:\/\/xcdn0.xgang-the-reboot.top\/wp-content\/uploads\/2026\/10\/\u901a\u7528\u767d\u677f-883x1024.png\" alt=\"\" class=\"wp-image-220\" srcset=\"https:\/\/xcdn0.xgang-the-reboot.top\/wp-content\/uploads\/2026\/10\/\u901a\u7528\u767d\u677f-883x1024.png 883w, https:\/\/xcdn0.xgang-the-reboot.top\/wp-content\/uploads\/2026\/10\/\u901a\u7528\u767d\u677f-259x300.png 259w, https:\/\/xcdn0.xgang-the-reboot.top\/wp-content\/uploads\/2026\/10\/\u901a\u7528\u767d\u677f-768x891.png 768w, https:\/\/xcdn0.xgang-the-reboot.top\/wp-content\/uploads\/2026\/10\/\u901a\u7528\u767d\u677f-1324x1536.png 1324w, https:\/\/xcdn0.xgang-the-reboot.top\/wp-content\/uploads\/2026\/10\/\u901a\u7528\u767d\u677f-1765x2048.png 1765w, https:\/\/xcdn0.xgang-the-reboot.top\/wp-content\/uploads\/2026\/10\/\u901a\u7528\u767d\u677f.png 1848w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4e2d\uff0c\u6bcf\u4e2a\u6307\u9488\u5fc5\u987b\u8981\u548c\u5176\u5bf9\u5e94\u7684\u53d8\u91cf <strong>\u7c7b\u578b\u76f8\u540c\uff01<\/strong>\u5426\u5219\u7f16\u8bd1\u5668\u76f4\u63a5\u62a5\u9519\u4e0d\u8ba9\u4f60\u8fc7\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u9488\u4e5f\u53ef\u4ee5\u8fdb\u884c\u52a0\u51cf\u8fd0\u7b97\uff0c\u4f46\u4ec5\u6b64\u800c\u5df2\uff0c\u4e0a\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-b-392-f-0-color has-text-color has-875-rem-font-size\"><code>    using namespace std ;\n    int something = 114514 ;\n    int *Ptr = &amp;something ;\n    cout &lt;&lt; \"something = \" &lt;&lt; something &lt;&lt; endl ;\n    cout &lt;&lt; \"PointOf \\\"something\\\" = \" &lt;&lt; Ptr &lt;&lt; endl ;\n    cout &lt;&lt; \"\u597d\u4e86\uff0c\u73b0\u5728\u7530\u6240\u6d69\u4e8c\u88ab\u4f60\u5f00\u76d2\u4e86\" &lt;&lt; endl\n         &lt;&lt; \"\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u5bf9\u7530\u6240\u6d69\u4e8c\u7684\u5bb6\u505a\u4e00\u70b9\u5c0f\u642c\u8fc1\" &lt;&lt; endl ;\n    Ptr++ ;\n    cout &lt;&lt; endl &lt;&lt; \"Ptr++ = \" &lt;&lt; Ptr &lt;&lt; endl\n         &lt;&lt; endl  ;\n\n    \/\/\u6307\u9488\u80fd\u4e0d\u80fd\u8fdb\u884c\u522b\u7684\u8fd0\u7b97\u5462\uff1f\n    Ptr = Ptr+2 ;\n    Ptr = Ptr + Ptr ; \/\/\u4e0d\u5408\u6cd5\uff1a\u6307\u9488\u4e4b\u95f4\u4e0d\u80fd\u52a0\u51cf\u4e58\u9664\n    Ptr = Ptr *2 ;    \/\/\u4e0d\u5408\u6cd5\uff1a\u6307\u9488\u4e0d\u80fd\u8fdb\u884c\u4efb\u4f55\u4e58\u9664\u64cd\u4f5c\n    Ptr = Ptr + something ; \/\/\u5408\u6cd5\uff1a\u6307\u9488\u53ef\u4ee5\u8fdb\u884c\u52a0\u51cf\uff08\u79fb\u52a8\u6240\u6307\u7684\u4f4d\u7f6e\uff09\u64cd\u4f5c\uff0c\u4f1a\u628a\u6574\u4e2a\u6307\u9488\u5bf9\u5e94\u7684\u5185\u5b58\u5757\u5f80\u524d\u5f80\u540e\u79fb\u52a8 n \u4e2a\u5143\u7d20\u4f4d\n                            \/\/\u6bd4\u5982\u4e00\u4e2a int \u662f 4\u5b57\u8282 \u90a3\u4e48\u6307\u9488\u5c31\u4f1a 4\u5b57\u8282 4\u5b57\u8282 \u5730\u79fb\u52a8<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u5b9a\u4e49\u4e00\u4e2a\u5783\u573e\u6307\u9488\uff08\u672a\u8fdb\u884c\u521d\u59cb\u5316\uff09\u4f1a\u600e\u4e48\u6837\u5462\uff1f\u770b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-b-392-f-0-color has-text-color has-875-rem-font-size\"><code>    int *Ptr1 ;\n    cout &lt;&lt; Ptr1 &lt;&lt; endl ; \/\/\u5728\u6211\u7684\u914d\u7f6e\u4e0b\uff0c\u8f93\u51fa\u6052\u4e3a 0x12000<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u9644\u5f55<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6bb5\u5185\u5bb9\u64b0\u5199\u7684\u4ee3\u7801\u539f\u6587\u5949\u4e0a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-b-392-f-0-color has-text-color has-875-rem-font-size\"><code>#include &lt;iostream>\n#include &lt;string>\n\nint main(){\n    using namespace std ;\n    int something = 114514 ;\n    int *Ptr = &amp;something ;\n    cout &lt;&lt; \"something = \" &lt;&lt; something &lt;&lt; endl ;\n    cout &lt;&lt; \"PointOf \\\"something\\\" = \" &lt;&lt; Ptr &lt;&lt; endl ;\n    cout &lt;&lt; \"\u597d\u4e86\uff0c\u73b0\u5728\u7530\u6240\u6d69\u4e8c\u88ab\u4f60\u5f00\u76d2\u4e86\" &lt;&lt; endl\n         &lt;&lt; \"\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u5bf9\u7530\u6240\u6d69\u4e8c\u7684\u5bb6\u505a\u4e00\u70b9\u5c0f\u642c\u8fc1\" &lt;&lt; endl ;\n    Ptr++ ;\n    cout &lt;&lt; endl &lt;&lt; \"Ptr++ = \" &lt;&lt; Ptr &lt;&lt; endl\n         &lt;&lt; endl  ;\n\n    \/\/\u6307\u9488\u80fd\u4e0d\u80fd\u8fdb\u884c\u522b\u7684\u8fd0\u7b97\u5462\uff1f\n    Ptr = Ptr+2 ;\n    \/\/ Ptr = Ptr + Ptr ; \/\/\u4e0d\u5408\u6cd5\uff1a\u6307\u9488\u4e4b\u95f4\u4e0d\u80fd\u52a0\u51cf\u4e58\u9664\n    \/\/ Ptr = Ptr *2 ;    \/\/\u4e0d\u5408\u6cd5\uff1a\u6307\u9488\u4e0d\u80fd\u8fdb\u884c\u4efb\u4f55\u4e58\u9664\u64cd\u4f5c\n    \/\/ Ptr = Ptr + something ; \/\/\u5408\u6cd5\uff1a\u6307\u9488\u53ef\u4ee5\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\uff0c\u4f1a\u628a\u6574\u4e2a\u53d8\u91cf\u5bf9\u5e94\u7684\u5185\u5b58\u5757\u5f80\u524d\u5f80\u540e\u79fb\u52a8 n \u4e2a\u5143\u7d20\u4f4d\n\n\n    cout &lt;&lt; \"Ptr+2 = \" &lt;&lt; Ptr &lt;&lt; endl\n         &lt;&lt; endl ;\n    \/\/\u65e2\u7136\u8fd9\u4e2a\u6307\u9488\u5bf9\u5e94\u7684\u4f4d\u7f6e\u51fa\u73b0\u53d8\u5316\u4e86\uff1f\u90a3\u6211\u8981\u662f\u83b7\u53d6\u4e00\u4e0b\u8fd9\u4e2a\u6307\u9488\u5bf9\u5e94\u7684\u503c\u4f1a\u600e\u4e48\u6837\u5462\uff1f\n    cout &lt;&lt; \"\u6765\u770b\u770b\u8fd8\u80fd\u4e0d\u80fd\u627e\u5230\u4eba\uff1a\" &lt;&lt; *Ptr &lt;&lt; endl \/\/\u4e0d\u80fd\u4e86\n         &lt;&lt; endl ;\n    cout &lt;&lt; \"\u6bcf\u6b21\u542f\u52a8\u7a0b\u5e8f\uff0c\u7530\u6240\u6d69\u4e8c\u7684\u5bb6\u90fd\u4f1a\u53d8\" &lt;&lt; endl\n         &lt;&lt; \"\u8fd9\u5c31\u662f\u6307\u9488\uff0c\u53ea\u662f\u4e2a\u5185\u5b58\u5730\u5740\u7f62\u4e86\uff0c\u5e76\u4e14\u4ee5\u6700\u5f00\u5934\u7684\u5b57\u8282\u4f5c\u4e3a\u6807\u8bc6\" &lt;&lt; endl\n         &lt;&lt; \"\u5982\u679c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\\\"\u5783\u573e\u6307\u9488\\\"\u4f1a\u600e\u4e48\u6837\u5462\uff1f\" &lt;&lt; endl ;\n    int *Ptr1 ;\n    cout &lt;&lt; Ptr1 &lt;&lt; endl ; \/\/\u5728\u6211\u7684\u914d\u7f6e\u4e0b\uff0c\u8f93\u51fa\u6052\u4e3a 0x12000\n\n    \/\/\u597d\uff0c\u5982\u679c\u6307\u9488\u7c7b\u578b\u548c\u5bf9\u5e94\u7684\u53d8\u91cf\u7c7b\u578b\u4e0d\u540c\u4f1a\u600e\u4e48\u6837\u5462\uff1f\n    string something2 = \"325799\";\n    \/\/ int *Ptr2 = something2 ; \/\/\u4e0d\u5408\u6cd5\u7684\u8d4b\u503c\uff1a\u65e0\u6cd5\u5c06\u5b57\u7b26\u4e32\u9690\u5f0f\u8f6c\u6362\u5230\u6574\u578b\n    return 0 ;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u70b9\u6240\u60f3\u6240\u5f97<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[7],"tags":[8],"class_list":["post-218","post","type-post","status-publish","format-standard","hentry","category-notes","tag-8"],"_links":{"self":[{"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/posts\/218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/comments?post=218"}],"version-history":[{"count":6,"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/posts\/218\/revisions"}],"predecessor-version":[{"id":226,"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/posts\/218\/revisions\/226"}],"wp:attachment":[{"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/media?parent=218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/categories?post=218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xgang-the-reboot.top\/index.php\/wp-json\/wp\/v2\/tags?post=218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}