{"id":2221,"date":"2025-03-24T08:47:58","date_gmt":"2025-03-23T23:47:58","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=2221"},"modified":"2025-03-24T08:48:22","modified_gmt":"2025-03-23T23:48:22","slug":"c%e6%bc%94%e7%ae%97%e5%ad%90%e3%82%aa%e3%83%bc%e3%83%90%e3%83%bc%e3%83%ad%e3%83%bc%e3%83%89%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a%e5%ae%9f%e8%b7%b5%e3%81%a7%e4%bd%bf%e3%81%88","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=2221","title":{"rendered":"C++\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u5b8c\u5168\u30ac\u30a4\u30c9\uff1a\u5b9f\u8df5\u3067\u4f7f\u3048\u308b7\u3064\u306e\u5fc5\u9808\u30c6\u30af\u30cb\u30c3\u30af"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u57fa\u790e\u77e5\u8b58<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3068\u306f\u4f55\u304b\uff1a\u7c21\u5358\u306a\u4f8b\u3067\u7406\u89e3\u3059\u308b<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-2\">\u306a\u305c\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u304c\u5fc5\u8981\u306a\u306e\u304b\uff1a\u5b9f\u969b\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-3\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u5b9f\u88c5\u65b9\u6cd5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-4\">\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\u3059\u308b\u30b1\u30fc\u30b9<\/a>      <\/li>      <li>        <a href=\"#i-5\">\u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\u3059\u308b\u30b1\u30fc\u30b9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-6\">\u30b0\u30ed\u30fc\u30d0\u30eb\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\u3059\u308b\u30b1\u30fc\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-7\">\u52b9\u679c\u7684\u306a\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e7\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-8\">1. const\u4fee\u98fe\u5b50\u3092\u6b63\u3057\u304f\u4f7f\u7528\u3059\u308b<\/a>      <\/li>      <li>        <a href=\"#i-9\">2. \u53c2\u7167\u6e21\u3057\u3067\u52b9\u7387\u3092\u5411\u4e0a\u3055\u305b\u308b<\/a>      <\/li>      <li>        <a href=\"#i-10\">3. \u5bfe\u79f0\u6027\u3092\u4fdd\u3064<\/a>      <\/li>      <li>        <a href=\"#i-11\">4. \u6f14\u7b97\u306e\u610f\u5473\u3092\u4fdd\u6301\u3059\u308b<\/a>      <\/li>      <li>        <a href=\"#i-12\">5. \u526f\u4f5c\u7528\u3092\u8003\u616e\u3059\u308b<\/a>      <\/li>      <li>        <a href=\"#i-13\">6. \u95a2\u9023\u3059\u308b\u6f14\u7b97\u5b50\u3092\u30bb\u30c3\u30c8\u3067\u5b9f\u88c5\u3059\u308b<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-14\">7. \u578b\u5909\u63db\u3092\u8003\u616e\u3059\u308b<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-15\">\u3088\u304f\u3042\u308b\u843d\u3068\u3057\u7a74\u3068\u89e3\u6c7a\u7b56<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-16\">\u30e1\u30e2\u30ea\u30ea\u30fc\u30af\u3092\u9632\u3050\u305f\u3081\u306e\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/a>      <\/li>      <li>        <a href=\"#i-17\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u306e\u56de\u907f\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-18\">\u30c7\u30d0\u30c3\u30b0\u304c\u56f0\u96e3\u306b\u306a\u308b\u30b1\u30fc\u30b9\u3068\u305d\u306e\u5bfe\u7b56<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-19\">\u5b9f\u8df5\u7684\u306a\u5b9f\u88c5\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-20\">\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u3067\u306e\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/a>      <\/li>      <li>        <a href=\"#i-21\">\u884c\u5217\u6f14\u7b97\u3067\u306e\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-22\">\u6587\u5b57\u5217\u6f14\u7b97\u3067\u306e\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-23\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-24\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u304c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u4e0e\u3048\u308b\u5f71\u97ff<\/a>      <\/li>      <li>        <a href=\"#i-25\">\u4fdd\u5b88\u6027\u3092\u9ad8\u3081\u308b\u305f\u3081\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-26\">\u5358\u4f53\u30c6\u30b9\u30c8\u306e\u52b9\u679c\u7684\u306a\u66f8\u304d\u65b9<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u57fa\u790e\u77e5\u8b58<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3068\u306f\u4f55\u304b\uff1a\u7c21\u5358\u306a\u4f8b\u3067\u7406\u89e3\u3059\u308b<\/h3>\n\n\n\n<p>\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3068\u306f\u3001C++\u306e\u30af\u30e9\u30b9\u3084\u69cb\u9020\u4f53\u306b\u5bfe\u3057\u3066\u6f14\u7b97\u5b50\u306e\u632f\u308b\u821e\u3044\u3092\u72ec\u81ea\u306b\u5b9a\u7fa9\u3059\u308b\u6a5f\u80fd\u3067\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u81ea\u4f5c\u30af\u30e9\u30b9\u3067\u3082\u7d44\u307f\u8fbc\u307f\u578b\u306e\u3088\u3046\u306b\u76f4\u611f\u7684\u306a\u6f14\u7b97\u5b50\u306e\u4f7f\u7528\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a2\u6b21\u5143\u30d9\u30af\u30c8\u30eb\u30af\u30e9\u30b9\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Vector2D {\nprivate:\n    double x, y;\n\npublic:\n    Vector2D(double x = 0, double y = 0) : x(x), y(y) {}\n\n    \/\/ \u52a0\u7b97\u6f14\u7b97\u5b50(+)\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    Vector2D operator+(const Vector2D&amp; other) const {\n        return Vector2D(x + other.x, y + other.y);\n    }\n\n    \/\/ \u51fa\u529b\u6f14\u7b97\u5b50(&lt;&lt;)\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\uff08\u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u3068\u3057\u3066\u5b9a\u7fa9\uff09\n    friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const Vector2D&amp; v) {\n        os &lt;&lt; \"(\" &lt;&lt; v.x &lt;&lt; \", \" &lt;&lt; v.y &lt;&lt; \")\";\n        return os;\n    }\n};<\/pre>\n\n\n\n<p>\u3053\u306e\u30af\u30e9\u30b9\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u76f4\u611f\u7684\u306a\u6f14\u7b97\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Vector2D v1(1.0, 2.0);\nVector2D v2(3.0, 4.0);\nVector2D v3 = v1 + v2;  \/\/ \u30d9\u30af\u30c8\u30eb\u306e\u52a0\u7b97\nstd::cout &lt;&lt; v3;        \/\/ (4, 6)\u3068\u51fa\u529b<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">\u306a\u305c\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u304c\u5fc5\u8981\u306a\u306e\u304b\uff1a\u5b9f\u969b\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/h3>\n\n\n\n<p>\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u91cd\u8981\u306a\u5229\u70b9\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6570\u5b66\u7684\u306a\u8868\u73fe\u3092\u305d\u306e\u307e\u307e\u30b3\u30fc\u30c9\u3067\u8868\u73fe\u53ef\u80fd<\/li>\n\n\n\n<li>\u8907\u96d1\u306a\u64cd\u4f5c\u3092\u7c21\u6f54\u306b\u8a18\u8ff0<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u578b\u306e\u62bd\u8c61\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e6\u30fc\u30b6\u30fc\u5b9a\u7fa9\u578b\u3092\u7d44\u307f\u8fbc\u307f\u578b\u306e\u3088\u3046\u306b\u6271\u3048\u308b<\/li>\n\n\n\n<li>API\u306e\u4e00\u8cab\u6027\u3092\u4fdd\u6301<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4fdd\u5b88\u6027\u306e\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6f14\u7b97\u306e\u5b9f\u88c5\u30921\u7b87\u6240\u306b\u96c6\u4e2d<\/li>\n\n\n\n<li>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u7d71\u4e00\u6027\u3092\u78ba\u4fdd<\/li>\n<\/ul>\n\n\n\n<p>\u4ee3\u8868\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\uff1a<\/p>\n\n\n<div id=\"id-d15cdb40-347a-46a6-8496-f0f3e7c63845\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/th><th>\u5177\u4f53\u4f8b<\/th><th>\u3088\u304f\u4f7f\u7528\u3055\u308c\u308b\u6f14\u7b97\u5b50<\/th><\/tr><\/thead><tbody><tr><td>\u6570\u5024\u6f14\u7b97<\/td><td>\u8907\u7d20\u6570\u3001\u884c\u5217\u3001\u30d9\u30af\u30c8\u30eb<\/td><td>+, -, *, \/, +=<\/td><\/tr><tr><td>\u30ea\u30bd\u30fc\u30b9\u7ba1\u7406<\/td><td>\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf<\/td><td>*, -&gt;, =, ==<\/td><\/tr><tr><td>\u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/td><td>\u30ab\u30b9\u30bf\u30e0\u30b3\u30f3\u30c6\u30ca<\/td><td>[], +=, &lt;&lt;<\/td><\/tr><tr><td>\u6587\u5b57\u5217\u64cd\u4f5c<\/td><td>\u72ec\u81ea\u6587\u5b57\u5217\u30af\u30e9\u30b9<\/td><td>+, +=, [], ==<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<p>\u9069\u5207\u306a\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u5f97\u3089\u308c\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u306e\u4f8b\nMySmartPtr&lt;int&gt; ptr(new int(42));\n*ptr = 100;  \/\/ \u76f4\u611f\u7684\u306a\u30dd\u30a4\u30f3\u30bf\u64cd\u4f5c\n\n\/\/ \u884c\u5217\u6f14\u7b97\u306e\u4f8b\nMatrix m1, m2;\nMatrix result = m1 * m2;  \/\/ \u884c\u5217\u306e\u4e57\u7b97\n\n\/\/ \u30ab\u30b9\u30bf\u30e0\u30b3\u30f3\u30c6\u30ca\u306e\u4f8b\nMyContainer&lt;int&gt; container;\ncontainer += 5;  \/\/ \u8981\u7d20\u306e\u8ffd\u52a0\nint value = container[0];  \/\/ \u8981\u7d20\u3078\u306e\u30a2\u30af\u30bb\u30b9<\/pre>\n\n\n\n<p>\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306f\u3001\u9069\u5207\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30b3\u30fc\u30c9\u306e\u8868\u73fe\u529b\u3068\u4fdd\u5b88\u6027\u3092\u5927\u304d\u304f\u5411\u4e0a\u3055\u305b\u308b\u5f37\u529b\u306a\u6a5f\u80fd\u3067\u3059\u3002\u305f\u3060\u3057\u3001\u305d\u306e\u4f7f\u7528\u306b\u306f\u4e00\u5b9a\u306e\u898f\u5247\u3068\u6ce8\u610f\u70b9\u304c\u3042\u308a\u3001\u3053\u308c\u3089\u306b\u3064\u3044\u3066\u306f\u5f8c\u7d9a\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-3\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u5b9f\u88c5\u65b9\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\u3059\u308b\u30b1\u30fc\u30b9<\/h3>\n\n\n\n<p>\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u6f14\u7b97\u5b50\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3059\u308b\u5834\u5408\u3001\u5de6\u30aa\u30da\u30e9\u30f3\u30c9\u306f\u6697\u9ed9\u7684\u306bthis\u30dd\u30a4\u30f3\u30bf\u3068\u306a\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5b9f\u88c5\u304c\u4e00\u822c\u7684\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Complex {\nprivate:\n    double real, imag;\n\npublic:\n    Complex(double r = 0, double i = 0) : real(r), imag(i) {}\n\n    \/\/ \u52a0\u7b97\u6f14\u7b97\u5b50\u306e\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u306e\u5b9f\u88c5\n    Complex operator+(const Complex&amp; other) const {\n        return Complex(real + other.real, imag + other.imag);\n    }\n\n    \/\/ \u4ee3\u5165\u6f14\u7b97\u5b50\u306e\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u306e\u5b9f\u88c5\n    Complex&amp; operator=(const Complex&amp; other) {\n        if (this != &amp;other) {  \/\/ \u81ea\u5df1\u4ee3\u5165\u30c1\u30a7\u30c3\u30af\n            real = other.real;\n            imag = other.imag;\n        }\n        return *this;\n    }\n\n    \/\/ \u6dfb\u5b57\u6f14\u7b97\u5b50\u306e\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u306e\u5b9f\u88c5\n    double&amp; operator[](int index) {\n        if (index == 0) return real;\n        if (index == 1) return imag;\n        throw std::out_of_range(\"Index must be 0 or 1\");\n    }\n};<\/pre>\n\n\n\n<p>\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\u3059\u3079\u304d\u4e3b\u306a\u6f14\u7b97\u5b50\uff1a<\/p>\n\n\n<div id=\"id-5f62dc29-9697-4b51-85cd-e088892963f0\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6f14\u7b97\u5b50<\/th><th>\u8aac\u660e<\/th><th>\u6ce8\u610f\u70b9<\/th><\/tr><\/thead><tbody><tr><td>=, [], ()<\/td><td>\u4ee3\u5165\u3001\u6dfb\u5b57\u3001\u95a2\u6570\u547c\u3073\u51fa\u3057<\/td><td>\u5fc5\u305a\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5<\/td><\/tr><tr><td>+=, -=, *=, \/=<\/td><td>\u8907\u5408\u4ee3\u5165<\/td><td>this\u306e\u72b6\u614b\u3092\u5909\u66f4\u3059\u308b\u305f\u3081<\/td><\/tr><tr><td>-&gt;, -&gt;*<\/td><td>\u30e1\u30f3\u30d0\u30a2\u30af\u30bb\u30b9<\/td><td>\u30dd\u30a4\u30f3\u30bf\u30e9\u30a4\u30af\u306a\u52d5\u4f5c\u306b\u4f7f\u7528<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\u3059\u308b\u30b1\u30fc\u30b9<\/h3>\n\n\n\n<p>\u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u306f\u3001\u30af\u30e9\u30b9\u306eprivate\u30e1\u30f3\u30d0\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u975e\u30e1\u30f3\u30d0\u95a2\u6570\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class String {\nprivate:\n    char* data;\n    size_t length;\n\npublic:\n    \/\/ \u6587\u5b57\u5217\u7d50\u5408\u6f14\u7b97\u5b50\u306e\u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u5ba3\u8a00\n    friend String operator+(const String&amp; left, const String&amp; right);\n\n    \/\/ \u30b9\u30c8\u30ea\u30fc\u30e0\u51fa\u529b\u6f14\u7b97\u5b50\u306e\u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u5ba3\u8a00\n    friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const String&amp; str);\n\n    \/\/ \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3068\u4ed6\u306e\u30e1\u30f3\u30d0\u95a2\u6570\u306e\u5b9f\u88c5...\n};\n\n\/\/ \u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u306e\u5b9f\u88c5\nString operator+(const String&amp; left, const String&amp; right) {\n    String result;\n    result.length = left.length + right.length;\n    result.data = new char[result.length + 1];\n    strcpy(result.data, left.data);\n    strcat(result.data, right.data);\n    return result;\n}\n\nstd::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const String&amp; str) {\n    os &lt;&lt; str.data;\n    return os;\n}<\/pre>\n\n\n\n<p>\u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u304c\u9069\u3057\u3066\u3044\u308b\u4e3b\u306a\u30b1\u30fc\u30b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5de6\u30aa\u30da\u30e9\u30f3\u30c9\u306e\u578b\u5909\u63db\u304c\u5fc5\u8981\u306a\u5834\u5408<\/li>\n\n\n\n<li>\u6f14\u7b97\u5b50\u306e\u5bfe\u79f0\u6027\u3092\u4fdd\u6301\u3057\u305f\u3044\u5834\u5408<\/li>\n\n\n\n<li>\u5165\u51fa\u529b\u30b9\u30c8\u30ea\u30fc\u30e0\u6f14\u7b97\u5b50\uff08&lt;&lt;, &gt;&gt;\uff09\u306e\u5b9f\u88c5<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">\u30b0\u30ed\u30fc\u30d0\u30eb\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\u3059\u308b\u30b1\u30fc\u30b9<\/h3>\n\n\n\n<p>\u30b0\u30ed\u30fc\u30d0\u30eb\u95a2\u6570\u306f\u3001\u30af\u30e9\u30b9\u306epublic\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u307f\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u88c5\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Time {\npublic:\n    int hours, minutes;\n    Time(int h = 0, int m = 0) : hours(h), minutes(m) {}\n\n    \/\/ getter\u30e1\u30bd\u30c3\u30c9\n    int getTotalMinutes() const { return hours * 60 + minutes; }\n    static Time fromTotalMinutes(int total) {\n        return Time(total \/ 60, total % 60);\n    }\n};\n\n\/\/ \u30b0\u30ed\u30fc\u30d0\u30eb\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\u3059\u308b\u5dee\u5206\u6f14\u7b97\u5b50\nTime operator-(const Time&amp; t1, const Time&amp; t2) {\n    int diff = t1.getTotalMinutes() - t2.getTotalMinutes();\n    return Time::fromTotalMinutes(std::abs(diff));\n}<\/pre>\n\n\n\n<p>\u5b9f\u88c5\u65b9\u6cd5\u306e\u9078\u629e\u57fa\u6e96\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30af\u30e9\u30b9\u306e\u72b6\u614b\u3092\u5909\u66f4\u3059\u308b\u6f14\u7b97\u5b50\uff08=, +=\u306a\u3069\uff09<\/li>\n\n\n\n<li>\u30af\u30e9\u30b9\u306b\u5bc6\u63a5\u306b\u7d50\u3073\u3064\u3044\u305f\u6f14\u7b97\uff08-&gt;\u306a\u3069\uff09<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5de6\u30aa\u30da\u30e9\u30f3\u30c9\u306e\u578b\u5909\u63db\u304c\u5fc5\u8981<\/li>\n\n\n\n<li>private\u30e1\u30f3\u30d0\u3078\u306e\u30a2\u30af\u30bb\u30b9\u304c\u5fc5\u8981<\/li>\n\n\n\n<li>\u6f14\u7b97\u5b50\u306e\u5bfe\u79f0\u6027\u304c\u91cd\u8981<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30b0\u30ed\u30fc\u30d0\u30eb\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>public\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u307f\u3067\u5b9f\u88c5\u53ef\u80fd<\/li>\n\n\n\n<li>\u30af\u30e9\u30b9\u306e\u5b9f\u88c5\u8a73\u7d30\u306b\u4f9d\u5b58\u3057\u306a\u3044<\/li>\n\n\n\n<li>\u6c4e\u7528\u7684\u306a\u6f14\u7b97\u5b50\u306e\u5b9f\u88c5<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u65b9\u6cd5\u3092\u9069\u5207\u306b\u9078\u629e\u3059\u308b\u3053\u3068\u3067\u3001\u4fdd\u5b88\u6027\u304c\u9ad8\u304f\u3001\u76f4\u611f\u7684\u306b\u4f7f\u7528\u3067\u304d\u308b\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-7\">\u52b9\u679c\u7684\u306a\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e7\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">1. const\u4fee\u98fe\u5b50\u3092\u6b63\u3057\u304f\u4f7f\u7528\u3059\u308b<\/h3>\n\n\n\n<p>const\u306e\u9069\u5207\u306a\u4f7f\u7528\u306f\u3001\u5b89\u5168\u6027\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u4e21\u65b9\u306b\u8ca2\u732e\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Number {\n    int value;\npublic:\n    Number(int v = 0) : value(v) {}\n\n    \/\/ \u5024\u3092\u5909\u66f4\u3057\u306a\u3044\u6f14\u7b97\u5b50\u306fconst\u3092\u4ed8\u3051\u308b\n    Number operator+(const Number&amp; other) const {\n        return Number(value + other.value);\n    }\n\n    \/\/ \u4ee3\u5165\u6f14\u7b97\u5b50\u306fconst\u306b\u3057\u306a\u3044\n    Number&amp; operator+=(const Number&amp; other) {\n        value += other.value;\n        return *this;\n    }\n\n    \/\/ const\u30e1\u30f3\u30d0\u95a2\u6570\u3068non-const\u30e1\u30f3\u30d0\u95a2\u6570\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    const int&amp; getValue() const { return value; }\n    int&amp; getValue() { return value; }\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-9\">2. \u53c2\u7167\u6e21\u3057\u3067\u52b9\u7387\u3092\u5411\u4e0a\u3055\u305b\u308b<\/h3>\n\n\n\n<p>\u5927\u304d\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30d4\u30fc\u3092\u907f\u3051\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Matrix {\n    std::vector&lt;std::vector&lt;double&gt;&gt; data;\npublic:\n    \/\/ \u5927\u304d\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f const \u53c2\u7167\u3067\u53d7\u3051\u53d6\u308b\n    Matrix&amp; operator*=(const Matrix&amp; other) {\n        \/\/ \u884c\u5217\u306e\u4e57\u7b97\u51e6\u7406\n        return *this;\n    }\n\n    \/\/ \u623b\u308a\u5024\u304c\u65b0\u3057\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5834\u5408\u306f\u5024\u8fd4\u3057\n    Matrix operator*(const Matrix&amp; other) const {\n        Matrix result = *this;\n        result *= other;\n        return result;  \/\/ RVO\/NRVO\u304c\u9069\u7528\u3055\u308c\u308b\n    }\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">3. \u5bfe\u79f0\u6027\u3092\u4fdd\u3064<\/h3>\n\n\n\n<p>\u6f14\u7b97\u5b50\u306e\u5bfe\u79f0\u6027\u306f\u3001\u76f4\u611f\u7684\u306aAPI\u306e\u91cd\u8981\u306a\u8981\u7d20\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Fraction {\n    int num, den;\npublic:\n    Fraction(int n = 0, int d = 1) : num(n), den(d) {}\n\n    \/\/ \u30e1\u30f3\u30d0\u95a2\u6570\u3068\u3057\u3066\u4e57\u7b97\u3092\u5b9a\u7fa9\n    Fraction operator*(const Fraction&amp; other) const {\n        return Fraction(num * other.num, den * other.den);\n    }\n\n    \/\/ \u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u3068\u3057\u3066\u5b9a\u7fa9\u3057\u3001int * Fraction \u3082\u53ef\u80fd\u306b\u3059\u308b\n    friend Fraction operator*(int left, const Fraction&amp; right) {\n        return Fraction(left) * right;\n    }\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nFraction f(1, 2);\nFraction result1 = f * 3;     \/\/ OK\nFraction result2 = 3 * f;     \/\/ \u3053\u308c\u3082 OK<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">4. \u6f14\u7b97\u306e\u610f\u5473\u3092\u4fdd\u6301\u3059\u308b<\/h3>\n\n\n\n<p>\u6f14\u7b97\u5b50\u306e\u4e00\u822c\u7684\u306a\u610f\u5473\u3084\u6570\u5b66\u7684\u306a\u6027\u8cea\u3092\u7dad\u6301\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class SafeInteger {\n    int value;\npublic:\n    SafeInteger(int v = 0) : value(v) {}\n\n    \/\/ \u52a0\u7b97\u306e\u6027\u8cea\u3092\u4fdd\u6301\n    SafeInteger operator+(const SafeInteger&amp; other) const {\n        if (__builtin_add_overflow(value, other.value, &amp;result)) {\n            throw std::overflow_error(\"Addition overflow\");\n        }\n        return SafeInteger(result);\n    }\n\n    \/\/ \u4e57\u7b97\u306e\u6027\u8cea\u3092\u4fdd\u6301\n    SafeInteger operator*(const SafeInteger&amp; other) const {\n        if (__builtin_mul_overflow(value, other.value, &amp;result)) {\n            throw std::overflow_error(\"Multiplication overflow\");\n        }\n        return SafeInteger(result);\n    }\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">5. \u526f\u4f5c\u7528\u3092\u8003\u616e\u3059\u308b<\/h3>\n\n\n\n<p>\u6f14\u7b97\u5b50\u306e\u526f\u4f5c\u7528\u306f\u3001\u4e88\u671f\u3057\u306a\u3044\u52d5\u4f5c\u306e\u539f\u56e0\u3068\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Counter {\n    int count;\npublic:\n    Counter(int c = 0) : count(c) {}\n\n    \/\/ \u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u6f14\u7b97\u5b50\u306e\u524d\u7f6e\u5f62\u5f0f\n    Counter&amp; operator++() {\n        ++count;\n        return *this;\n    }\n\n    \/\/ \u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u6f14\u7b97\u5b50\u306e\u5f8c\u7f6e\u5f62\u5f0f\uff08\u526f\u4f5c\u7528\u306b\u6ce8\u610f\uff09\n    Counter operator++(int) {\n        Counter temp = *this;  \/\/ \u73fe\u5728\u306e\u72b6\u614b\u3092\u4fdd\u5b58\n        ++count;              \/\/ \u72b6\u614b\u3092\u66f4\u65b0\n        return temp;          \/\/ \u53e4\u3044\u5024\u3092\u8fd4\u3059\n    }\n\n    \/\/ \u6bd4\u8f03\u6f14\u7b97\u5b50\u306f\u526f\u4f5c\u7528\u3092\u6301\u305f\u306a\u3044\n    bool operator&lt;(const Counter&amp; other) const {\n        return count &lt; other.count;  \/\/ \u72b6\u614b\u3092\u5909\u66f4\u3057\u306a\u3044\n    }\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">6. \u95a2\u9023\u3059\u308b\u6f14\u7b97\u5b50\u3092\u30bb\u30c3\u30c8\u3067\u5b9f\u88c5\u3059\u308b<\/h3>\n\n\n\n<p>\u95a2\u9023\u3059\u308b\u6f14\u7b97\u5b50\u306f\u3001\u4e00\u8cab\u6027\u306e\u3042\u308b\u52d5\u4f5c\u3092\u4fdd\u8a3c\u3059\u308b\u305f\u3081\u306b\u30bb\u30c3\u30c8\u3067\u5b9f\u88c5\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class String {\n    char* data;\npublic:\n    \/\/ \u6bd4\u8f03\u6f14\u7b97\u5b50\u3092\u30bb\u30c3\u30c8\u3067\u5b9f\u88c5\n    bool operator==(const String&amp; other) const {\n        return strcmp(data, other.data) == 0;\n    }\n    bool operator!=(const String&amp; other) const {\n        return !(*this == other);\n    }\n    bool operator&lt;(const String&amp; other) const {\n        return strcmp(data, other.data) &lt; 0;\n    }\n    bool operator&gt;(const String&amp; other) const {\n        return other &lt; *this;\n    }\n    bool operator&lt;=(const String&amp; other) const {\n        return !(other &lt; *this);\n    }\n    bool operator&gt;=(const String&amp; other) const {\n        return !(*this &lt; other);\n    }\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">7. \u578b\u5909\u63db\u3092\u8003\u616e\u3059\u308b<\/h3>\n\n\n\n<p>\u6697\u9ed9\u306e\u578b\u5909\u63db\u3068\u660e\u793a\u7684\u306a\u578b\u5909\u63db\u3092\u9069\u5207\u306b\u5236\u5fa1\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Rational {\n    int num, den;\npublic:\n    \/\/ \u6697\u9ed9\u306e\u578b\u5909\u63db\u3092\u8a31\u53ef\n    Rational(int n) : num(n), den(1) {}\n\n    \/\/ \u660e\u793a\u7684\u306a\u578b\u5909\u63db\u306e\u307f\u3092\u8a31\u53ef\n    explicit Rational(double d) {\n        const int scale = 10000;\n        num = static_cast&lt;int&gt;(d * scale);\n        den = scale;\n        normalize();\n    }\n\n    \/\/ \u4ed6\u306e\u578b\u3078\u306e\u5909\u63db\u6f14\u7b97\u5b50\n    explicit operator double() const {\n        return static_cast&lt;double&gt;(num) \/ den;\n    }\n\nprivate:\n    void normalize() {\n        \/\/ \u5206\u6570\u306e\u7d04\u5206\u51e6\u7406\n    }\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nRational r1 = 5;          \/\/ OK: \u6697\u9ed9\u306e\u578b\u5909\u63db\nRational r2(3.14);        \/\/ OK: \u660e\u793a\u7684\u306a\u69cb\u7bc9\ndouble d = double(r1);    \/\/ OK: \u660e\u793a\u7684\u306a\u5909\u63db\n\/\/ double d2 = r1;        \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc: \u6697\u9ed9\u306e\u5909\u63db\u306f\u7981\u6b62<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e7\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u5b89\u5168\u3067\u52b9\u7387\u7684\u3001\u304b\u3064\u4f7f\u3044\u3084\u3059\u3044\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002\u5404\u30c6\u30af\u30cb\u30c3\u30af\u306f\u3001\u30b3\u30fc\u30c9\u306e\u54c1\u8cea\u5411\u4e0a\u306b\u91cd\u8981\u306a\u5f79\u5272\u3092\u679c\u305f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-15\">\u3088\u304f\u3042\u308b\u843d\u3068\u3057\u7a74\u3068\u89e3\u6c7a\u7b56<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">\u30e1\u30e2\u30ea\u30ea\u30fc\u30af\u3092\u9632\u3050\u305f\u3081\u306e\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/h3>\n\n\n\n<p>\u30e1\u30e2\u30ea\u7ba1\u7406\u306f\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306b\u304a\u3051\u308b\u6700\u3082\u91cd\u8981\u306a\u8ab2\u984c\u306e\u4e00\u3064\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u4e3b\u306a\u554f\u984c\u30d1\u30bf\u30fc\u30f3\u3068\u89e3\u6c7a\u7b56\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class DynamicArray {\n    int* data;\n    size_t size;\n\npublic:\n    \/\/ \u554f\u984c\u306e\u3042\u308b\u5b9f\u88c5\n    DynamicArray&amp; operator=(const DynamicArray&amp; other) {\n        data = new int[other.size];  \/\/ \u30e1\u30e2\u30ea\u30ea\u30fc\u30af\u306e\u53ef\u80fd\u6027\u3042\u308a\n        size = other.size;\n        std::copy(other.data, other.data + size, data);\n        return *this;\n    }\n\n    \/\/ \u6b63\u3057\u3044\u5b9f\u88c5\uff08\u30b3\u30d4\u30fc\u30fb\u30a2\u30f3\u30c9\u30fb\u30b9\u30ef\u30c3\u30d7\u30fb\u30a4\u30c7\u30a3\u30aa\u30e0\uff09\n    DynamicArray&amp; operator=(DynamicArray other) {\n        swap(*this, other);  \/\/ \u4e00\u6642\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u30b9\u30ef\u30c3\u30d7\n        return *this;\n    }\n\n    friend void swap(DynamicArray&amp; first, DynamicArray&amp; second) noexcept {\n        using std::swap;\n        swap(first.data, second.data);\n        swap(first.size, second.size);\n    }\n\n    \/\/ \u79fb\u52d5\u4ee3\u5165\u6f14\u7b97\u5b50\n    DynamicArray&amp; operator=(DynamicArray&amp;&amp; other) noexcept {\n        if (this != &amp;other) {\n            delete[] data;\n            data = other.data;\n            size = other.size;\n            other.data = nullptr;\n            other.size = 0;\n        }\n        return *this;\n    }\n};<\/pre>\n\n\n\n<p>\u30e1\u30e2\u30ea\u30ea\u30fc\u30af\u9632\u6b62\u306e\u305f\u3081\u306e\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8\uff1a<\/p>\n\n\n<div id=\"id-dfdabe9b-f34a-475c-b040-c68e7c2ea82d\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30c1\u30a7\u30c3\u30af\u9805\u76ee<\/th><th>\u5b9f\u88c5\u30dd\u30a4\u30f3\u30c8<\/th><th>\u52b9\u679c<\/th><\/tr><\/thead><tbody><tr><td>\u81ea\u5df1\u4ee3\u5165\u30c1\u30a7\u30c3\u30af<\/td><td>if (this != &amp;other)<\/td><td>\u4e0d\u8981\u306a\u30b3\u30d4\u30fc\u3068\u7834\u58ca\u3092\u9632\u3050<\/td><\/tr><tr><td>\u4f8b\u5916\u5b89\u5168\u6027<\/td><td>\u30b9\u30ef\u30c3\u30d7\u624b\u6cd5\u306e\u4f7f\u7528<\/td><td>\u30ea\u30bd\u30fc\u30b9\u306e\u5b89\u5168\u306a\u79fb\u52d5<\/td><\/tr><tr><td>\u30ea\u30bd\u30fc\u30b9\u89e3\u653e<\/td><td>\u30c7\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u306e\u78ba\u5b9f\u306a\u89e3\u653e<\/td><td>\u30e1\u30e2\u30ea\u30ea\u30fc\u30af\u306e\u9632\u6b62<\/td><\/tr><tr><td>\u30e0\u30fc\u30d6\u30bb\u30de\u30f3\u30c6\u30a3\u30af\u30b9<\/td><td>\u79fb\u52d5\u6f14\u7b97\u5b50\u306e\u5b9f\u88c5<\/td><td>\u52b9\u7387\u7684\u306a\u30ea\u30bd\u30fc\u30b9\u8ee2\u9001<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u306e\u56de\u907f\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306b\u304a\u3051\u308b\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306e\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class BigNumber {\n    std::vector&lt;int&gt; digits;\n\npublic:\n    \/\/ \u975e\u52b9\u7387\u306a\u5b9f\u88c5\n    BigNumber operator+(const BigNumber&amp; other) {\n        BigNumber result;\n        \/\/ ... \u8a08\u7b97\u51e6\u7406 ...\n        return result;  \/\/ \u4e0d\u8981\u306a\u30b3\u30d4\u30fc\u304c\u767a\u751f\n    }\n\n    \/\/ \u52b9\u7387\u7684\u306a\u5b9f\u88c5\n    BigNumber&amp; operator+=(const BigNumber&amp; other) {\n        \/\/ \u76f4\u63a5this\u3092\u4fee\u6b63\n        return *this;\n    }\n\n    \/\/ \u52b9\u7387\u7684\u306a\u52a0\u7b97\u6f14\u7b97\u5b50\uff08+=\u3092\u5229\u7528\uff09\n    friend BigNumber operator+(BigNumber left, const BigNumber&amp; right) {\n        left += right;  \/\/ \u65e2\u5b58\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u518d\u5229\u7528\n        return left;    \/\/ RVO\u304c\u9069\u7528\u3055\u308c\u308b\n    }\n};<\/pre>\n\n\n\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306e\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4e0d\u8981\u306a\u30b3\u30d4\u30fc\u306e\u524a\u6e1b<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u53c2\u7167\u6e21\u3057\u306e\u6d3b\u7528<\/li>\n\n\n\n<li>\u79fb\u52d5\u30bb\u30de\u30f3\u30c6\u30a3\u30af\u30b9\u306e\u5229\u7528<\/li>\n\n\n\n<li>RVO\/NRVO\u306e\u6d3b\u7528<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30e1\u30e2\u30ea\u30a2\u30ed\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u6700\u9069\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e1\u30e2\u30ea\u306e\u4e8b\u524d\u78ba\u4fdd<\/li>\n\n\n\n<li>\u4e00\u6642\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u524a\u6e1b<\/li>\n\n\n\n<li>\u30d7\u30fc\u30eb\u30a2\u30ed\u30b1\u30fc\u30bf\u306e\u4f7f\u7528<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u30c7\u30d0\u30c3\u30b0\u304c\u56f0\u96e3\u306b\u306a\u308b\u30b1\u30fc\u30b9\u3068\u305d\u306e\u5bfe\u7b56<\/h3>\n\n\n\n<p>\u30c7\u30d0\u30c3\u30b0\u3092\u5bb9\u6613\u306b\u3059\u308b\u305f\u3081\u306e\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class DebugString {\n    std::string data;\n    static bool debug_mode;\n\npublic:\n    \/\/ \u30c7\u30d0\u30c3\u30b0\u60c5\u5831\u4ed8\u304d\u306e\u6f14\u7b97\u5b50\n    DebugString operator+(const DebugString&amp; other) const {\n        if (debug_mode) {\n            std::cout &lt;&lt; \"Concatenating: '\" &lt;&lt; data \n                      &lt;&lt; \"' with '\" &lt;&lt; other.data &lt;&lt; \"'\\n\";\n        }\n        return DebugString(data + other.data);\n    }\n\n    \/\/ \u6bd4\u8f03\u6f14\u7b97\u5b50\u306e\u30c7\u30d0\u30c3\u30b0\u5bfe\u5fdc\u7248\n    bool operator==(const DebugString&amp; other) const {\n        bool result = (data == other.data);\n        if (debug_mode) {\n            std::cout &lt;&lt; \"Comparing: '\" &lt;&lt; data \n                      &lt;&lt; \"' with '\" &lt;&lt; other.data \n                      &lt;&lt; \"' -&gt; \" &lt;&lt; result &lt;&lt; \"\\n\";\n        }\n        return result;\n    }\n\n    \/\/ \u30c7\u30d0\u30c3\u30b0\u30e2\u30fc\u30c9\u306e\u5236\u5fa1\n    static void enableDebug(bool enable) {\n        debug_mode = enable;\n    }\n};\n\nbool DebugString::debug_mode = false;<\/pre>\n\n\n\n<p>\u30c7\u30d0\u30c3\u30b0\u5bb9\u6613\u6027\u3092\u9ad8\u3081\u308b\u305f\u3081\u306e\u30c6\u30af\u30cb\u30c3\u30af\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ed\u30b0\u6a5f\u80fd\u306e\u7d44\u307f\u8fbc\u307f<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6f14\u7b97\u5b50\u306e\u547c\u3073\u51fa\u3057\u6642\u306e\u72b6\u614b\u8a18\u9332<\/li>\n\n\n\n<li>\u5165\u529b\u5024\u3068\u7d50\u679c\u306e\u8ffd\u8de1<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u72b6\u6cc1\u306e\u8a73\u7d30\u306a\u8a18\u9332<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306e\u6d3b\u7528<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u524d\u6761\u4ef6\u3068\u5f8c\u6761\u4ef6\u306e\u691c\u8a3c<\/li>\n\n\n\n<li>\u4e0d\u5909\u6761\u4ef6\u306e\u30c1\u30a7\u30c3\u30af<\/li>\n\n\n\n<li>\u30a8\u30c3\u30b8\u30b1\u30fc\u30b9\u306e\u691c\u51fa<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c7\u30d0\u30c3\u30b0\u30d3\u30eb\u30c9\u7528\u306e\u8ffd\u52a0\u6a5f\u80fd<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u72b6\u614b\u5909\u5316\u306e\u76e3\u8996<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u72b6\u6cc1\u306e\u8ffd\u8de1<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30d7\u30ed\u30d5\u30a1\u30a4\u30ea\u30f3\u30b0<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5bfe\u7b56\u3092\u9069\u5207\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306b\u95a2\u3059\u308b\u591a\u304f\u306e\u4e00\u822c\u7684\u306a\u554f\u984c\u3092\u56de\u907f\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-19\">\u5b9f\u8df5\u7684\u306a\u5b9f\u88c5\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u3067\u306e\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/h3>\n\n\n\n<p>\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u306f\u3001\u30ea\u30bd\u30fc\u30b9\u7ba1\u7406\u3092\u81ea\u52d5\u5316\u3059\u308b\u91cd\u8981\u306a\u6a5f\u80fd\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u57fa\u672c\u7684\u306a\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">template&lt;typename T&gt;\nclass SmartPtr {\n    T* ptr;\n\npublic:\n    SmartPtr(T* p = nullptr) : ptr(p) {}\n\n    ~SmartPtr() {\n        delete ptr;\n    }\n\n    \/\/ \u30c7\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u6f14\u7b97\u5b50\n    T&amp; operator*() const {\n        if (!ptr) throw std::runtime_error(\"Null pointer access\");\n        return *ptr;\n    }\n\n    \/\/ \u30e1\u30f3\u30d0\u30a2\u30af\u30bb\u30b9\u6f14\u7b97\u5b50\n    T* operator-&gt;() const {\n        if (!ptr) throw std::runtime_error(\"Null pointer access\");\n        return ptr;\n    }\n\n    \/\/ \u6bd4\u8f03\u6f14\u7b97\u5b50\n    bool operator==(const SmartPtr&amp; other) const {\n        return ptr == other.ptr;\n    }\n\n    \/\/ \u79fb\u52d5\u30bb\u30de\u30f3\u30c6\u30a3\u30af\u30b9\n    SmartPtr(SmartPtr&amp;&amp; other) noexcept : ptr(other.ptr) {\n        other.ptr = nullptr;\n    }\n\n    SmartPtr&amp; operator=(SmartPtr&amp;&amp; other) noexcept {\n        if (this != &amp;other) {\n            delete ptr;\n            ptr = other.ptr;\n            other.ptr = nullptr;\n        }\n        return *this;\n    }\n\n    \/\/ \u30b3\u30d4\u30fc\u6f14\u7b97\u306e\u7981\u6b62\n    SmartPtr(const SmartPtr&amp;) = delete;\n    SmartPtr&amp; operator=(const SmartPtr&amp;) = delete;\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nclass Resource {\npublic:\n    void doSomething() { std::cout &lt;&lt; \"Resource used\\n\"; }\n};\n\nSmartPtr&lt;Resource&gt; createResource() {\n    return SmartPtr&lt;Resource&gt;(new Resource());\n}\n\nvoid useResource() {\n    auto res = createResource();\n    res-&gt;doSomething();  \/\/ \u81ea\u52d5\u7684\u306b\u30ea\u30bd\u30fc\u30b9\u7ba1\u7406\n}  \/\/ res\u306e\u30c7\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u81ea\u52d5\u89e3\u653e<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-21\">\u884c\u5217\u6f14\u7b97\u3067\u306e\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/h3>\n\n\n\n<p>\u6570\u5024\u8a08\u7b97\u3067\u3088\u304f\u4f7f\u7528\u3055\u308c\u308b\u884c\u5217\u30af\u30e9\u30b9\u306e\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Matrix {\n    std::vector&lt;std::vector&lt;double&gt;&gt; data;\n    size_t rows, cols;\n\npublic:\n    Matrix(size_t r, size_t c) : rows(r), cols(c), \n        data(r, std::vector&lt;double&gt;(c, 0.0)) {}\n\n    \/\/ \u6dfb\u5b57\u6f14\u7b97\u5b50\uff082\u6b21\u5143\u30a2\u30af\u30bb\u30b9\uff09\n    std::vector&lt;double&gt;&amp; operator[](size_t i) {\n        if (i &gt;= rows) throw std::out_of_range(\"Row index out of range\");\n        return data[i];\n    }\n\n    \/\/ \u884c\u5217\u306e\u52a0\u7b97\n    Matrix operator+(const Matrix&amp; other) const {\n        if (rows != other.rows || cols != other.cols) {\n            throw std::invalid_argument(\"Matrix dimensions mismatch\");\n        }\n        Matrix result(rows, cols);\n        for (size_t i = 0; i &lt; rows; ++i) {\n            for (size_t j = 0; j &lt; cols; ++j) {\n                result.data[i][j] = data[i][j] + other.data[i][j];\n            }\n        }\n        return result;\n    }\n\n    \/\/ \u884c\u5217\u306e\u4e57\u7b97\n    Matrix operator*(const Matrix&amp; other) const {\n        if (cols != other.rows) {\n            throw std::invalid_argument(\"Matrix dimensions mismatch\");\n        }\n        Matrix result(rows, other.cols);\n        for (size_t i = 0; i &lt; rows; ++i) {\n            for (size_t j = 0; j &lt; other.cols; ++j) {\n                for (size_t k = 0; k &lt; cols; ++k) {\n                    result.data[i][j] += data[i][k] * other.data[k][j];\n                }\n            }\n        }\n        return result;\n    }\n\n    \/\/ \u30b9\u30ab\u30e9\u30fc\u500d\n    Matrix operator*(double scalar) const {\n        Matrix result(rows, cols);\n        for (size_t i = 0; i &lt; rows; ++i) {\n            for (size_t j = 0; j &lt; cols; ++j) {\n                result.data[i][j] = data[i][j] * scalar;\n            }\n        }\n        return result;\n    }\n\n    \/\/ \u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u3068\u3057\u3066\u306e\u30b9\u30ab\u30e9\u30fc\u500d\uff08\u5de6\u304b\u3089\u639b\u3051\u308b\u5834\u5408\uff09\n    friend Matrix operator*(double scalar, const Matrix&amp; mat) {\n        return mat * scalar;\n    }\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-22\">\u6587\u5b57\u5217\u6f14\u7b97\u3067\u306e\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/h3>\n\n\n\n<p>\u30ab\u30b9\u30bf\u30e0\u6587\u5b57\u5217\u30af\u30e9\u30b9\u306e\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CustomString {\n    std::string data;\n\npublic:\n    CustomString(const char* str = \"\") : data(str) {}\n\n    \/\/ \u6587\u5b57\u5217\u7d50\u5408\n    CustomString operator+(const CustomString&amp; other) const {\n        return CustomString((data + other.data).c_str());\n    }\n\n    \/\/ \u8907\u5408\u4ee3\u5165\u6f14\u7b97\u5b50\n    CustomString&amp; operator+=(const CustomString&amp; other) {\n        data += other.data;\n        return *this;\n    }\n\n    \/\/ \u6dfb\u5b57\u6f14\u7b97\u5b50\n    char&amp; operator[](size_t index) {\n        if (index &gt;= data.length()) {\n            throw std::out_of_range(\"String index out of range\");\n        }\n        return data[index];\n    }\n\n    \/\/ \u6bd4\u8f03\u6f14\u7b97\u5b50\n    bool operator&lt;(const CustomString&amp; other) const {\n        return data &lt; other.data;\n    }\n\n    \/\/ \u7e70\u308a\u8fd4\u3057\u6f14\u7b97\u5b50\n    CustomString operator*(unsigned int n) const {\n        std::string result;\n        result.reserve(data.length() * n);\n        for (unsigned int i = 0; i &lt; n; ++i) {\n            result += data;\n        }\n        return CustomString(result.c_str());\n    }\n\n    \/\/ \u30b9\u30c8\u30ea\u30fc\u30e0\u51fa\u529b\u6f14\u7b97\u5b50\n    friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, \n                                  const CustomString&amp; str) {\n        os &lt;&lt; str.data;\n        return os;\n    }\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nvoid stringOperations() {\n    CustomString s1(\"Hello\");\n    CustomString s2(\" World\");\n\n    \/\/ \u6587\u5b57\u5217\u7d50\u5408\n    CustomString s3 = s1 + s2;\n\n    \/\/ \u7e70\u308a\u8fd4\u3057\n    CustomString repeated = s1 * 3;  \/\/ \"HelloHelloHello\"\n\n    \/\/ \u6dfb\u5b57\u30a2\u30af\u30bb\u30b9\n    char ch = s3[0];  \/\/ 'H'\n\n    \/\/ \u30b9\u30c8\u30ea\u30fc\u30e0\u51fa\u529b\n    std::cout &lt;&lt; s3 &lt;&lt; std::endl;\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u4f7f\u7528\u3067\u304d\u308b\u5b9f\u8df5\u7684\u306a\u30b3\u30fc\u30c9\u3067\u3059\u3002\u305d\u308c\u305e\u308c\u306e\u30b1\u30fc\u30b9\u3067\u3001\u578b\u306e\u5b89\u5168\u6027\u3001\u52b9\u7387\u6027\u3001\u4f7f\u3044\u3084\u3059\u3055\u3092\u8003\u616e\u3057\u305f\u8a2d\u8a08\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-23\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-24\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u304c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u4e0e\u3048\u308b\u5f71\u97ff<\/h3>\n\n\n\n<p>\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6700\u9069\u5316\u3059\u308b\u305f\u3081\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3068\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class BigInteger {\n    std::vector&lt;uint32_t&gt; digits;\n\npublic:\n    \/\/ \u975e\u52b9\u7387\u306a\u5b9f\u88c5\n    BigInteger operator+(const BigInteger&amp; other) const {\n        BigInteger result;\n        result.digits.reserve(std::max(digits.size(), other.digits.size()) + 1);\n        \/\/ ... \u52a0\u7b97\u51e6\u7406 ...\n        return result;\n    }\n\n    \/\/ \u52b9\u7387\u7684\u306a\u5b9f\u88c5\uff08\u30e1\u30e2\u30ea\u518d\u78ba\u4fdd\u306e\u6700\u5c0f\u5316\uff09\n    BigInteger&amp; operator+=(const BigInteger&amp; other) {\n        \/\/ \u30e1\u30e2\u30ea\u306e\u4e8b\u524d\u78ba\u4fdd\n        if (digits.size() &lt; other.digits.size()) {\n            digits.reserve(other.digits.size() + 1);\n        }\n        \/\/ ... \u52a0\u7b97\u51e6\u7406 ...\n        return *this;\n    }\n\n    \/\/ \u79fb\u52d5\u30bb\u30de\u30f3\u30c6\u30a3\u30af\u30b9\u3092\u6d3b\u7528\u3057\u305f\u5b9f\u88c5\n    BigInteger operator+(BigInteger&amp;&amp; other) noexcept {\n        other += *this;  \/\/ \u53f3\u8fba\u5024\u3092\u76f4\u63a5\u4fee\u6b63\n        return std::move(other);\n    }\n\n    \/\/ SSE\/AVX\u3092\u6d3b\u7528\u3057\u305f\u6700\u9069\u5316\u4f8b\n    BigInteger&amp; operator*=(const BigInteger&amp; other) {\n        #ifdef __AVX2__\n        \/\/ AVX2\u547d\u4ee4\u30bb\u30c3\u30c8\u3092\u4f7f\u7528\u3057\u305f\u9ad8\u901f\u306a\u4e57\u7b97\n        multiplyAVX2(other);\n        #else\n        \/\/ \u901a\u5e38\u306e\u4e57\u7b97\u51e6\u7406\n        multiplyNormal(other);\n        #endif\n        return *this;\n    }\n};<\/pre>\n\n\n\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff1a<\/p>\n\n\n<div id=\"id-8fe380b9-1240-4239-acc1-a35aa6bbf6f7\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6700\u9069\u5316\u624b\u6cd5<\/th><th>\u52b9\u679c<\/th><th>\u9069\u7528\u30b1\u30fc\u30b9<\/th><\/tr><\/thead><tbody><tr><td>\u79fb\u52d5\u30bb\u30de\u30f3\u30c6\u30a3\u30af\u30b9<\/td><td>\u4e0d\u8981\u306a\u30b3\u30d4\u30fc\u3092\u524a\u6e1b<\/td><td>\u5927\u304d\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u6f14\u7b97<\/td><\/tr><tr><td>\u30e1\u30e2\u30ea\u30d7\u30ea\u30a2\u30ed\u30b1\u30fc\u30b7\u30e7\u30f3<\/td><td>\u518d\u78ba\u4fdd\u306e\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9\u524a\u6e1b<\/td><td>\u53ef\u5909\u30b5\u30a4\u30ba\u306e\u30b3\u30f3\u30c6\u30ca<\/td><\/tr><tr><td>SIMD\u547d\u4ee4\u306e\u6d3b\u7528<\/td><td>\u6f14\u7b97\u306e\u4e26\u5217\u5316<\/td><td>\u6570\u5024\u6f14\u7b97\u306e\u9ad8\u901f\u5316<\/td><\/tr><tr><td>\u5f0f\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<\/td><td>\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306e\u6700\u9069\u5316<\/td><td>\u8907\u96d1\u306a\u6570\u5f0f\u306e\u8a55\u4fa1<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"i-25\">\u4fdd\u5b88\u6027\u3092\u9ad8\u3081\u308b\u305f\u3081\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<p>\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306e\u9ad8\u3044\u30b3\u30fc\u30c9\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306e\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Vector3D {\npublic:\n    \/\/ \u660e\u78ba\u306a\u540d\u524d\u4ed8\u3051\u898f\u5247\n    static const Vector3D ZERO;\n    static const Vector3D UNIT_X;\n\n    \/\/ \u6f14\u7b97\u5b50\u306e\u4e00\u8cab\u6027\u3092\u4fdd\u3064\n    Vector3D&amp; operator+=(const Vector3D&amp; other) {\n        x += other.x;\n        y += other.y;\n        z += other.z;\n        return *this;\n    }\n\n    \/\/ \u95a2\u9023\u3059\u308b\u6f14\u7b97\u5b50\u3092\u307e\u3068\u3081\u3066\u5b9f\u88c5\n    friend Vector3D operator+(Vector3D left, const Vector3D&amp; right) {\n        return left += right;\n    }\n\n    \/\/ \u9069\u5207\u306a\u30b3\u30e1\u30f3\u30c8\u3068\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\n    \/**\n     * @brief \u30d9\u30af\u30c8\u30eb\u306e\u30c9\u30c3\u30c8\u7a4d\u3092\u8a08\u7b97\n     * @param other \u8a08\u7b97\u5bfe\u8c61\u306e\u30d9\u30af\u30c8\u30eb\n     * @return \u30c9\u30c3\u30c8\u7a4d\u306e\u7d50\u679c\n     * @throws std::invalid_argument \u30d9\u30af\u30c8\u30eb\u304c\u4e0d\u6b63\u306a\u5834\u5408\n     *\/\n    double operator*(const Vector3D&amp; other) const {\n        return x * other.x + y * other.y + z * other.z;\n    }\n\nprivate:\n    double x, y, z;\n\n    \/\/ \u5185\u90e8\u5b9f\u88c5\u306e\u8a73\u7d30\u3092\u96a0\u853d\n    void normalize() {\n        double length = std::sqrt(x * x + y * y + z * z);\n        if (length &gt; 0) {\n            x \/= length;\n            y \/= length;\n            z \/= length;\n        }\n    }\n};<\/pre>\n\n\n\n<p>\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u5411\u4e0a\u306e\u305f\u3081\u306e\u30ac\u30a4\u30c9\u30e9\u30a4\u30f3\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30b3\u30fc\u30c9\u306e\u69cb\u9020\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u95a2\u9023\u3059\u308b\u6f14\u7b97\u5b50\u3092\u30b0\u30eb\u30fc\u30d7\u5316<\/li>\n\n\n\n<li>\u4e00\u8cab\u3057\u305f\u547d\u540d\u898f\u5247<\/li>\n\n\n\n<li>\u9069\u5207\u306a\u53ef\u8996\u6027\u5236\u5fa1<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30a8\u30e9\u30fc\u51e6\u7406<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f8b\u5916\u306e\u9069\u5207\u306a\u4f7f\u7528<\/li>\n\n\n\n<li>\u5883\u754c\u6761\u4ef6\u306e\u51e6\u7406<\/li>\n\n\n\n<li>\u4e0d\u5909\u6761\u4ef6\u306e\u7dad\u6301<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>API\u4ed5\u69d8\u306e\u660e\u78ba\u5316<\/li>\n\n\n\n<li>\u4f7f\u7528\u4f8b\u306e\u63d0\u4f9b<\/li>\n\n\n\n<li>\u5236\u7d04\u6761\u4ef6\u306e\u660e\u793a<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-26\">\u5358\u4f53\u30c6\u30b9\u30c8\u306e\u52b9\u679c\u7684\u306a\u66f8\u304d\u65b9<\/h3>\n\n\n\n<p>\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ComplexNumberTest : public ::testing::Test {\nprotected:\n    Complex a{3.0, 4.0};\n    Complex b{1.0, 2.0};\n};\n\n\/\/ \u57fa\u672c\u7684\u306a\u6f14\u7b97\u306e\u30c6\u30b9\u30c8\nTEST_F(ComplexNumberTest, Addition) {\n    Complex c = a + b;\n    EXPECT_DOUBLE_EQ(c.real(), 4.0);\n    EXPECT_DOUBLE_EQ(c.imag(), 6.0);\n}\n\n\/\/ \u30a8\u30c3\u30b8\u30b1\u30fc\u30b9\u306e\u30c6\u30b9\u30c8\nTEST_F(ComplexNumberTest, DivisionByZero) {\n    Complex zero;\n    EXPECT_THROW(a \/ zero, std::invalid_argument);\n}\n\n\/\/ \u30d7\u30ed\u30d1\u30c6\u30a3\u30c6\u30b9\u30c8\nTEST_F(ComplexNumberTest, AdditionCommutative) {\n    EXPECT_EQ(a + b, b + a);\n}\n\n\/\/ \u6027\u80fd\u30c6\u30b9\u30c8\nTEST_F(ComplexNumberTest, PerformanceBenchmark) {\n    const int iterations = 1000000;\n    auto start = std::chrono::high_resolution_clock::now();\n\n    Complex result;\n    for (int i = 0; i &lt; iterations; ++i) {\n        result += a;\n    }\n\n    auto end = std::chrono::high_resolution_clock::now();\n    auto duration = std::chrono::duration_cast&lt;std::chrono::microseconds&gt;\n                   (end - start).count();\n\n    EXPECT_LT(duration, 1000000);  \/\/ 1\u79d2\u4ee5\u5185\u306b\u5b8c\u4e86\u3059\u308b\u3053\u3068\n}<\/pre>\n\n\n\n<p>\u52b9\u679c\u7684\u306a\u30c6\u30b9\u30c8\u6226\u7565\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u5206\u985e<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u57fa\u672c\u6a5f\u80fd\u30c6\u30b9\u30c8<\/li>\n\n\n\n<li>\u30a8\u30c3\u30b8\u30b1\u30fc\u30b9\u30c6\u30b9\u30c8<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c6\u30b9\u30c8<\/li>\n\n\n\n<li>\u56de\u5e30\u30c6\u30b9\u30c8<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c6\u30b9\u30c8\u7bc4\u56f2\u306e\u78ba\u4fdd<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u3059\u3079\u3066\u306e\u6f14\u7b97\u5b50\u306e\u7db2\u7f85<\/li>\n\n\n\n<li>\u7570\u5e38\u7cfb\u306e\u30c6\u30b9\u30c8<\/li>\n\n\n\n<li>\u5883\u754c\u5024\u306e\u30c6\u30b9\u30c8<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c6\u30b9\u30c8\u306e\u81ea\u52d5\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3078\u306e\u7d44\u307f\u8fbc\u307f<\/li>\n\n\n\n<li>\u5b9a\u671f\u7684\u306a\u5b9f\u884c<\/li>\n\n\n\n<li>\u7d50\u679c\u306e\u81ea\u52d5\u691c\u8a3c<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u8df5\u306b\u3088\u308a\u3001\u9ad8\u6027\u80fd\u3067\u4fdd\u5b88\u6027\u306e\u9ad8\u3044\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u5b9f\u88c5\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":{"0":"post-2221","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-cpp","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2221"}],"version-history":[{"count":1,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2221\/revisions"}],"predecessor-version":[{"id":2222,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2221\/revisions\/2222"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}