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

            我參與的團隊

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 454864
            • 排名 - 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 閱讀(2549) 評論(0)  編輯 收藏 引用
            国产农村妇女毛片精品久久| 精品乱码久久久久久久| 成人综合伊人五月婷久久| 亚洲日本va中文字幕久久| 无码精品久久久天天影视| 99热成人精品热久久669| 国产2021久久精品| 亚洲人成无码www久久久| 亚洲综合伊人久久综合| 狠色狠色狠狠色综合久久| 精品久久久久久久中文字幕| 久久热这里只有精品在线观看| 国产精品一区二区久久精品涩爱| 男女久久久国产一区二区三区| 9久久9久久精品| 精品国产乱码久久久久久人妻| 久久AV高清无码| 国产精品久久久久蜜芽| 久久亚洲国产精品一区二区| 国内精品久久久久影院老司| 亚洲欧美精品伊人久久| 精品久久久无码21p发布| 久久99精品国产99久久6| 亚洲精品蜜桃久久久久久| 久久综合日本熟妇| 一本久久a久久精品综合夜夜| 国产A三级久久精品| 亚洲性久久久影院| 久久久WWW免费人成精品| 久久香蕉一级毛片| 久久99精品久久久久久久不卡| 久久妇女高潮几次MBA| 亚洲国产香蕉人人爽成AV片久久| 色综合久久久久| 久久精品无码一区二区三区| 久久婷婷五月综合97色一本一本| 伊人久久大香线蕉综合5g| 久久久久国产一级毛片高清板 | 久久婷婷色综合一区二区| 久久国产成人| 国产精品美女久久久久av爽|