• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            doing5552

            記錄每日點滴,不枉人生一世

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              73 Posts :: 0 Stories :: 94 Comments :: 0 Trackbacks

            公告

            常用鏈接

            留言簿(24)

            我參與的團隊

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 455403
            • 排名 - 49

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            自定義類
            class arc {
            ……
            bool operator<(const arc& b) const;

            }

            用容器如vector,deque存放arc對象,再其上使用stl的algrithms中的sort算法:
            sort(arcVector.begin(),arcVector.end());

            方法中需要使用“<”作比較操作,故需要重載operator<
            簡單重載 bool operator(arc&);
            很可能報錯:
            /usr/include/c++/4.2/bits/stl_algo.h:100: 錯誤: no match 為‘operator<’在‘__b < __c’
            主要是缺少const的限定(兩個都需要)。
            否則有錯:
            /usr/include/c++/4.2/bits/stl_algo.h:91: 錯誤: 將‘const arc’作為‘bool arc::operator<(const arc&)’的‘this’實參時丟棄了類型限定

            分析知道linux中stl下對C++的類型安全約束很強,const保證導入對象和自身對象都不能被修改。
            而stl的sort操作確實不需要修改比較的對象,也不應該被修改,故強制使用的自定義operator<需要兩個const限制比較的兩個對象。

            使用friend方法:
            friend bool operator<(const arc&, const arc&);

            兩種錯誤:
            1.friend bool operator<(const arc&, const arc&) const;
            錯誤: non-成員函數‘bool operator<(const arc&, const arc&)’不能擁有 cv 限定符

            2.bool operator<(const arc&, const arc&) [const]
            錯誤: ‘bool arc::operator<(const arc&, const arc&) const’帶且僅帶 1 個實參
            posted on 2011-02-15 17:32 doing5552 閱讀(2557) 評論(0)  編輯 收藏 引用
            三级三级久久三级久久| 国产一级做a爰片久久毛片| 无码乱码观看精品久久| 久久婷婷五月综合国产尤物app| 久久国产亚洲精品| 97精品伊人久久大香线蕉app | 中文字幕无码久久人妻| 久久久无码精品亚洲日韩按摩| 中文字幕久久欲求不满| 狠狠色丁香婷婷久久综合| 久久中文字幕一区二区| 久久精品国产色蜜蜜麻豆| 久久99久久无码毛片一区二区| 久久久亚洲欧洲日产国码是AV| 国产成人精品久久一区二区三区 | 精品久久久久久中文字幕| 久久午夜无码鲁丝片午夜精品| 亚洲AV乱码久久精品蜜桃| 久久人妻少妇嫩草AV蜜桃| 久久婷婷五月综合色高清| 亚洲国产婷婷香蕉久久久久久| 91精品国产综合久久四虎久久无码一级 | 国产AⅤ精品一区二区三区久久| 一级a性色生活片久久无| 久久福利青草精品资源站免费| 伊人久久精品无码av一区| 日本久久久久久久久久| 久久青青草原精品国产不卡| 91精品免费久久久久久久久| 狠狠色丁香婷婷综合久久来| 久久男人Av资源网站无码软件| 久久99九九国产免费看小说| 色诱久久av| 久久久久免费精品国产| 久久无码AV中文出轨人妻| 伊人久久成人成综合网222| 婷婷久久综合| 久久婷婷国产剧情内射白浆 | 日日狠狠久久偷偷色综合免费| 久久久久久国产精品免费免费| 久久五月精品中文字幕|