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

            concentrate on c/c++ related technology

            plan,refactor,daily-build, self-discipline,

              C++博客 :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
              37 Posts :: 1 Stories :: 12 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(9)

            我參與的團(tuán)隊(duì)

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            const 常量函數(shù)只能調(diào)用其中的常量相關(guān)的東西。
            struct StringLess:
             public std::binary_function<const std::string&,
                    const std::string&,
                    bool>
            {
             bool operator()(const std::string& a, const std::string& b)const
             {
              return strcmp(a.c_str(),b.c_str());
             }
            };

            std::map<std::string,Core::Rtti*,StringLess> nameTable;
             Core::Rtti* Factory::GetRttiName(std::string className)const
             {
              return this->nameTable[className];
             }
            但是還發(fā)現(xiàn)出現(xiàn)錯(cuò)誤。
            g:\framework\foundation\foundation\core\factory.cpp(60) : error C2678: 二進(jìn)制“[”: 沒(méi)有找到接受“const std::map<_Kty,_Ty,_Pr>”類型的左操作數(shù)的運(yùn)算符(或沒(méi)有可接受的轉(zhuǎn)換)
                    with
                    [
                        _Kty=std::string,
                        _Ty=Core::Rtti *,
                        _Pr=StringLess
                    ]
                    e:\microsoft visual studio 8\vc\include\map(166): 可能是“Core::Rtti *&std::map<_Kty,_Ty,_Pr>::operator [](const std::basic_string<_Elem,_Traits,_Ax> &)”
                    with
                    [
                        _Kty=std::string,
                        _Ty=Core::Rtti *,
                        _Pr=StringLess,
                        _Elem=char,
                        _Traits=std::char_traits<char>,
                        _Ax=std::allocator<char>
                    ]
                    試圖匹配參數(shù)列表“(const std::map<_Kty,_Ty,_Pr>, std::string)”時(shí)
                    with
                    [
                        _Kty=std::string,
                        _Ty=Core::Rtti *,
                        _Pr=StringLess
                    ]
            這里主要是const函數(shù)的濫用,因?yàn)椴磺宄onst函數(shù)究竟能對(duì)什么進(jìn)行操作就濫用。
            map的const對(duì)象不可以調(diào)[]。
            operator[] 不是 const類型。
            所以這個(gè)錯(cuò)誤基本上將const去掉就好了。
            這里總結(jié)一些東西,以前也濫用過(guò)const的東西
            返回const表示這個(gè)返回內(nèi)容是只讀的,不能被修改的。
            參數(shù)使用const表示這個(gè)參數(shù)是只讀的,而不能進(jìn)行任何修改,只參與計(jì)算,而不修改本身。
            const常函數(shù),只能對(duì)常量進(jìn)行操作,說(shuō)明在這里主要是進(jìn)行常量成員的操作,而不做任何與const無(wú)關(guān)的操作,上面就是個(gè)很好的例子。
            posted on 2008-09-03 10:20 jolley 閱讀(1612) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            国产亚洲美女精品久久久久狼| 亚洲精品无码久久毛片| 伊人久久大香线焦AV综合影院 | 精品无码久久久久久尤物| 国内精品久久久久影院薰衣草| 久久狠狠爱亚洲综合影院| 久久国产精品99国产精| 日韩亚洲欧美久久久www综合网| 久久久久久久综合日本| 久久久久久久女国产乱让韩| 97精品伊人久久大香线蕉app | 久久综合一区二区无码| 国内高清久久久久久| 91精品国产高清久久久久久国产嫩草| 人人狠狠综合88综合久久| 久久久久久亚洲精品成人| 久久青青草原精品国产软件| 国产午夜福利精品久久2021| 久久久久久一区国产精品| 99久久99这里只有免费费精品| 伊人热热久久原色播放www| 99热热久久这里只有精品68| 久久人人爽人人爽人人AV| 久久99精品久久久久久秒播| 久久精品欧美日韩精品| 伊人久久大香线蕉精品不卡| 伊人丁香狠狠色综合久久| 久久婷婷激情综合色综合俺也去| 伊人久久大香线蕉综合网站| 久久激情五月丁香伊人| 国产精品综合久久第一页| 欧美激情精品久久久久| 精品久久香蕉国产线看观看亚洲| 久久精品国产亚洲av高清漫画 | 久久婷婷色香五月综合激情| 亚洲午夜久久久精品影院| 久久精品国产久精国产思思| 亚洲精品乱码久久久久久久久久久久 | 国内精品久久久久影院老司| 久久免费观看视频| 久久天天躁夜夜躁狠狠|