• <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++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
              73 Posts :: 0 Stories :: 94 Comments :: 0 Trackbacks

            公告

            常用鏈接

            留言簿(24)

            我參與的團隊

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 455263
            • 排名 - 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-成員函數(shù)‘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| 国产精品中文久久久久久久| 久久久久久久久久久精品尤物| 亚洲国产精品综合久久网络| 久久久久久久人妻无码中文字幕爆| 国产91色综合久久免费| 久久丝袜精品中文字幕| 久久久久久久亚洲Av无码| 日韩欧美亚洲国产精品字幕久久久| 久久综合九色综合网站| 超级碰久久免费公开视频| 久久久久久久久波多野高潮| 国产亚洲成人久久| 亚洲精品无码成人片久久| 国内精品久久久久久久涩爱| 热re99久久精品国99热| 一本大道久久香蕉成人网| 久久91精品国产91久久户| 久久伊人精品一区二区三区| 91精品国产91久久久久久青草| 色综合久久久久久久久五月| 思思久久99热只有频精品66| 亚洲嫩草影院久久精品| 国产成人综合久久综合| 无码人妻精品一区二区三区久久 | 久久综合给合久久狠狠狠97色69| 久久99精品国产99久久6| 狠狠色丁香婷婷久久综合不卡| 伊人久久大香线蕉综合Av| 久久久久亚洲AV片无码下载蜜桃| 久久久久久噜噜精品免费直播| 伊人久久大香线焦综合四虎| 免费国产99久久久香蕉| 久久精品国产91久久麻豆自制| 久久99精品久久久久久久久久| 久久久久人妻一区精品性色av| 伊人久久精品无码av一区| 青青草原精品99久久精品66| 久久青青草原精品国产| 久久发布国产伦子伦精品| 国产成人精品久久免费动漫|