• <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)

            我參與的團隊

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 455274
            • 排名 - 48

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            自定義類
            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 閱讀(2556) 評論(0)  編輯 收藏 引用
            中文字幕日本人妻久久久免费 | 亚洲AV成人无码久久精品老人| 久久久久国产一级毛片高清板| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 国产免费久久久久久无码| 欧美激情精品久久久久久| 青青草原综合久久大伊人| 久久99精品久久久久久久不卡| 国产高清国内精品福利99久久| 日韩电影久久久被窝网| 久久99精品久久久久婷婷| 亚洲国产成人精品久久久国产成人一区二区三区综 | 久久这里只精品国产99热| 亚洲国产日韩欧美久久| 97久久精品午夜一区二区| 精品综合久久久久久88小说 | 97久久精品午夜一区二区| 怡红院日本一道日本久久 | 欧美精品一本久久男人的天堂| 超级97碰碰碰碰久久久久最新 | 久久综合九色欧美综合狠狠| 久久人人爽爽爽人久久久| 美女久久久久久| 久久久91人妻无码精品蜜桃HD| 日日噜噜夜夜狠狠久久丁香五月 | 青青草国产精品久久久久| 久久无码AV一区二区三区| 99久久精品无码一区二区毛片| 无码国内精品久久人妻蜜桃| 色综合久久久久综合99| 99久久国产综合精品五月天喷水 | 2021最新久久久视精品爱| 久久久久亚洲AV成人网人人软件| 精品免费久久久久久久| 久久人人爽人人爽人人av东京热| 久久成人永久免费播放| 99久久夜色精品国产网站| 欧美激情精品久久久久| 亚洲国产精品久久久久婷婷老年| 国产一区二区三区久久| 久久99中文字幕久久|