{"id":147,"date":"2025-02-21T21:29:33","date_gmt":"2025-02-21T13:29:33","guid":{"rendered":"https:\/\/www.czjun.cn\/?p=147"},"modified":"2025-03-05T00:16:18","modified_gmt":"2025-03-04T16:16:18","slug":"%e5%ad%a6%e5%a5%bd-c-%e7%9a%84%e5%85%b3%e9%94%ae%e8%bd%ac%e5%8f%98","status":"publish","type":"post","link":"https:\/\/www.czjun.cn\/?p=147","title":{"rendered":"\u5b66\u597dC++\u7684\u6838\u5fc3\u7406\u8bba\u8981\u70b9"},"content":{"rendered":"\n<p>\u5f53\u4f60\u8ba4\u4e3a C++ \u662f\u9762\u5411\u5bf9\u8c61\u7684\u8bed\u8a00\u7684\u65f6\u5019\uff0c\u4f60\u5c31\u6c38\u8fdc\u5b66\u4e0d\u4f1a C++\u3002<br><br>\u6070\u6070\u5927\u90e8\u5206\u5b66\u4e86 C \u7684\u4eba\uff0c\u90fd\u4f1a\u8ba4\u4e3a C++ \u4e0d\u8fc7\u662f C \u4e0a\u52a0\u4e86\u201c\u5bf9\u8c61\u201d\u3002\u65e2\u7136\u662f C with class, \u4ed6\u81ea\u7136\u5c31\u5f88\u81ea\u4fe1\u7684\u8ba4\u4e3a\u81ea\u5df1\u5f88\u5feb\u5c31\u80fd\u5b66\u4f1aC++\u3002<br><br>C++ \u4e0d\u8fc7\u5c14\u5c14\u3002<br><br><br>\u4f46\u662f\uff0c\u5f53\u4ed6\u6709\u4e00\u5929\uff0c\u9700\u8981\u4f7f\u7528C++\u7684\u65f6\u5019\uff0c\u5f88\u5feb\u4ed6\u5c31\u4f1a\u611f\u5230\u5de8\u5927\u7684\u632b\u8d25\u611f\u3002<br>\u56e0\u4e3aC++\u9664\u4e86 C with Class \uff0c\u5269\u4e0b\u7684\u4e1c\u897f\u4ed6\u6ca1\u4e00\u4e2a\u80fd\u61c2\u7684\u3002<br><br>C++ \u771f\u7684\u662f\u592a\u590d\u6742\u5566\uff01<br><br>\u8fd9\u5c31\u662f\u5927\u90e8\u5206\u4eba C++ \u4ece\u5165\u95e8\u5230\u653e\u5f03\u7684\u539f\u56e0\u3002<br><br><br>\u5982\u679c\u653e\u5f03\u81ea\u4ee5\u4e3a\u662f\u7684\u9762\u5411\u5bf9\u8c61\u7684\u6210\u89c1\uff0c\u597d\u597d\u7684\u5b66\u4e60 C++\uff0c\u5c31\u4f1a\u53d1\u73b0\uff0c C++\u5176\u5b9e\u662f\u4e2a\u9762\u5411\u201c\u6982\u5ff5\u201d\u7f16\u7a0b\u7684\u8bed\u8a00\u3002<br><br>C++ \u7684\u4e00\u5207\u7279\u6027\uff0c\u90fd\u662f\u4e3a\u4e86 0 \u5f00\u9500\u62bd\u8c61 \u201c\u6982\u5ff5\u201d\u3002<br><br>\u4e3a\u4f55\u4f1a\u6709\u6a21\u677f\uff1f<br>\u56e0\u4e3a\uff0c\u540c\u4e00\u4e2a\u6982\u5ff5\uff0c\u7528\u540c\u4e00\u4efd\u4ee3\u7801\u3002\u800c\u4e0d\u7ba1\u8fd9\u4e2a\u6982\u5ff5\u80cc\u540e\u7684\u771f\u5b9e\u6570\u636e\u7c7b\u578b\u3002\u6bd4\u5982 std::sort, \u4ed6\u5c31\u662f\u6392\u5e8f\u3002\u53ea\u8981\u80fd\u6bd4\u8f83\u5927\u5c0f\u7684\uff0c\u5c31\u80fd\u6392\u5e8f\u3002\u4f60\u7ba1\u4ed6\u662f int \u8fd8\u662f char \u8fd8\u662ffloat, \u751a\u81f3\u8fde string \u90fd\u80fd\u6392\u5e8f\u3002\u53ea\u8981\u80fd\u6ee1\u8db3 \u201c\u53ef\u6bd4\u8f83\u5927\u5c0f\u201d \u8fd9\u4e2a\u6982\u5ff5\u7684\uff0c\u90fd\u8981\u80fd\u6392\u5e8f\u3002<br><br>\u65e2\u7136\u6392\u5e8f\uff0c\u5c31\u5f97\u6709\u5bb9\u5668\u3002\u6392\u5e8f\u6392\u5e8f\uff0c\u5f97\u6709\u4e2a\u5bb9\u5668\uff0c\u628a\u4e1c\u897f\u653e\u91cc\u9762\u6392\u6392\u653e\uff0c\u90a3\u624d\u6709\u987a\u5e8f\u7684\u6982\u5ff5\u3002<br>\u4e8e\u662f\u5c31\u6709\u4e86 \u201c\u5bb9\u5668\u201d \u7684\u6982\u5ff5\u3002\u4e3a\u4e86\u64cd\u4f5c\u5bb9\u5668\uff0c\u5c31\u8981\u5bf9\u5bb9\u5668\u8fdb\u884c\u66f4\u9ad8\u7a0b\u5ea6\u7684\u62bd\u8c61\uff0c\u4e8e\u662f\u5c31\u6709\u4e86 \u201c\u8fed\u4ee3\u5668\u201d\u7684\u6982\u5ff5\u3002\u8fed\u4ee3\u5668\uff0c\u5c31\u662f\u7528\u6765\u8bbf\u95ee\u5bb9\u5668\u91cc\u5b58\u50a8\u7684\u5bf9\u8c61\u7684\u3002\u662f\u5bb9\u5668\u7684\u6293\u624b\u3002<br><br>\u6709\u4e86\u5bb9\u5668\uff0c\u5c31\u6709\u4e86\u201c\u5bf9\u8c61\u201d\u751f\u547d\u671f\u7684\u7ba1\u7406\u9700\u6c42\u3002\u5bf9\u8c61\u653e\u5165\u5bb9\u5668\uff0c\u62ff\u51fa\u5bb9\u5668\uff0c\u5b83\u5230\u5e95\u4f55\u53bb\u4f55\u4ece\u3002<br>\u4e8e\u662f\u5c31\u6709\u4e86\u53f3\u503c\u5f15\u7528\u548c\u5de6\u503c\u5f15\u7528\u7684\u6982\u5ff5\uff0c\u8fd9\u6837\u5c31\u80fd\u8bbe\u8ba1\u51fa \u62f7\u8d1d\u6784\u9020\u548c\u79fb\u52a8\u6784\u9020\u3002<br>\u6709\u4e86\u62f7\u8d1d\u548c\u79fb\u52a8\u7684\u6982\u5ff5\uff0c\u624d\u80fd\u8bbe\u8ba1\u51fa\u6027\u80fd\u66f4\u597d\u7684\u5bb9\u5668\u3002\u5bf9\u8c61\u662f\u88ab\u79fb\u52a8\u5230\u5bb9\u5668\u91cc\u7684\uff0c\u800c\u4e0d\u662f\u62f7\u8d1d\u8fdb\u53bb\u7684\u3002\u8fd9\u5c31\u5927\u5927\u964d\u4f4e\u4e86\u4f7f\u7528\u5bb9\u5668\u5b58\u50a8\u201c\u5927\u5bf9\u8c61\u201d\u7684\u5f00\u9500\u3002<br><br>\u8fd9\u4e9b\u90fd\u6709\u4e86\uff0c\u53c8\u53d1\u73b0\uff0c\u5982\u679c\u7528\u9519\u4e86\u5bf9\u8c61\uff0c\u5bf9\u8c61\u548c\u6a21\u677f\u5e0c\u671b\u7684\u201c\u6982\u5ff5\u201d\u4e0d\u5339\u914d\uff0c\u7f16\u8bd1\u51fa\u9519\u5c31\u4f1a\u975e\u5e38\u75af\u72c2\u3002<br>\u4e8e\u662f\u5c31\u6709\u4e86 &#8220;concept&#8221; \u5173\u952e\u5b57\u3002\u52a0\u4e0a\u4e86\u6a21\u677f\u53c2\u6570\u7ea6\u675f\u529f\u80fd\u3002<br><br>\u5f88\u591a\u65f6\u5019\uff0c\u4e00\u4e2a\u901a\u7528\u6982\u5ff5\u4e0b\uff0c\u603b\u4f1a\u6709\u4e00\u4e9b\u201c\u7279\u4f8b\u201d\u3002\u4e3a\u8fd9\u4e9b\u7279\u4f8b\u6309\u6392\u5355\u72ec\u7684\u4ee3\u7801\uff0c\u4e0d\u5171\u4eab\u901a\u7528\u7684\u6a21\u677f\u4ee3\u7801\uff0c\u5c31\u53ef\u4ee5\u66f4\u597d\u7684\u201c\u4f18\u5316\u201d\u6027\u80fd\u3002\u4e8e\u662f\u5c31\u6709\u4e86 \u201c\u6a21\u677f\u7279\u5316\u201d \u529f\u80fd\u3002<br><br>\u6a21\u677f\u7279\u5316\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5b9e\u73b0\u6982\u5ff5\u3002\u6bd4\u5982 \u5bb9\u5668\u4e00\u822c\u4f1a\u5bf9 \u666e\u901a\u7684\u201c\u5bf9\u8c61\u201d \u548c \u7b80\u5355\u7684\u5185\u7f6e\u7c7b\u578b\u5bf9\u8c61\uff0c\u4f7f\u7528\u4e0d\u540c\u7684\u4ee3\u7801\u3002\u56e0\u4e3a\u5185\u7f6e\u7c7b\u578b\u6ca1\u6709\u201c\u6784\u9020\u51fd\u6570\u201d\u3002\u4e8e\u662f\uff0c\u5bb9\u5668\u7684\u6a21\u677f\uff0c\u5c31\u4f1a\u5bf9\u7b80\u5355\u7c7b\u578b\u8fdb\u884c\u7279\u5316\u3002\u8fd9\u6837\u7684\u7279\u5316\u4ee3\u7801\uff0c\u5bf9\u65e0\u6784\u9020\u51fd\u6570\uff0c\u65e0\u6790\u6784\u51fd\u6570\u7684\u5bf9\u8c61\uff0c\u8fdb\u884c\u9488\u5bf9\u6027\u7684\u4f18\u5316\u3002<br><br>\u4f46\u662f\uff0c\u65e0\u6784\u9020\u51fd\u6570\u7684\uff0c\u96be\u9053\u53ea\u662f\u5185\u7f6e\u7c7b\u578b\u5417\uff1f \u7528\u6237\u5199\u7684\u5bf9\u8c61\uff0c\u4e5f\u53ef\u4ee5\u65e0\u6784\u9020\u51fd\u6570\u3002\u4e8e\u662f\uff0c\u8fd9\u79cd\u6a21\u677f\u7279\u5316\uff0c\u5c31\u4e0d\u662f\u4e3a\u5177\u4f53\u7c7b\u578b\u8fdb\u884c\u7279\u5316\uff0c\u800c\u662f\u5bf9\u67d0\u4e2a\u7ec6\u5206\u7684\u201c\u6982\u5ff5\u201d\u8fdb\u884c \u4e00\u534a\u7684\u7279\u5316\u3002\u8fd9\u79cd\u4e00\u534a\u7684\u7279\u5316\uff0c\u5c31\u53eb \u6a21\u677f\u504f\u7279\u5316\u3002 \u4e5f\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5b9e\u73b0 \u9762\u5411\u6982\u5ff5\u7f16\u7a0b\u3002<br><br>\u6240\u4ee5\u4f60\u770b\uff0c\u4e00\u5207 \u5b66\u4e0d\u4f1a\u7684 C++ \u7279\u6027\uff0c\u90fd\u662f\u56e0\u4e3a\u4ed6\u8fd8\u5728\u4f7f\u7528\u201c\u9762\u5411\u5bf9\u8c61\u201d\u8fd9\u79cd\u601d\u7ef4\u65b9\u5f0f\u3002<br><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u4f5c\u8005\uff1amicrocai<br>\u94fe\u63a5\uff1ahttps:\/\/www.zhihu.com\/question\/647517330\/answer\/26517814740<br>\u6765\u6e90\uff1a\u77e5\u4e4e<br>\u8457\u4f5c\u6743\u5f52\u4f5c\u8005\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u83b7\u5f97\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u4f60\u8ba4\u4e3a C++ \u662f\u9762\u5411\u5bf9\u8c61\u7684\u8bed\u8a00\u7684\u65f6\u5019\uff0c\u4f60\u5c31\u6c38\u8fdc\u5b66\u4e0d\u4f1a C++\u3002 \u6070\u6070\u5927\u90e8\u5206\u5b66\u4e86 C \u7684\u4eba\uff0c\u90fd\u4f1a\u8ba4\u4e3a C++ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","_jetpack_memberships_contains_paid_content":false,"ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[46],"tags":[54,57,53,52,58,55,56],"class_list":{"0":"post-147","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-46","7":"tag-c","10":"tag-52","11":"tag-58","12":"tag-55","13":"tag-56","14":"entry"},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.czjun.cn\/index.php?rest_route=\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.czjun.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.czjun.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.czjun.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.czjun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=147"}],"version-history":[{"count":9,"href":"https:\/\/www.czjun.cn\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":234,"href":"https:\/\/www.czjun.cn\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions\/234"}],"wp:attachment":[{"href":"https:\/\/www.czjun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.czjun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.czjun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}