• <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 閱讀(1614) 評(píng)論(0)  編輯 收藏 引用

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


            狠狠色丁香久久综合五月| 中文成人久久久久影院免费观看| 99久久国产免费福利| 欧洲性大片xxxxx久久久| 色偷偷偷久久伊人大杳蕉| 国产香蕉97碰碰久久人人| 婷婷伊人久久大香线蕉AV | 国产精品久久久久国产A级| 久久精品国产99久久丝袜| 色欲av伊人久久大香线蕉影院| 久久99精品久久久久久久久久| 成人精品一区二区久久| 91精品国产91久久综合| 性高湖久久久久久久久| 99久久精品九九亚洲精品| 麻豆久久久9性大片| 亚洲午夜精品久久久久久浪潮 | 久久66热人妻偷产精品9| 99久久99久久精品国产片| 日韩中文久久| 国内精品欧美久久精品| 亚洲AV无码久久| 中文字幕久久亚洲一区| 91亚洲国产成人久久精品网址| 少妇人妻88久久中文字幕| 亚洲精品久久久www| 久久99久久无码毛片一区二区| 国产V综合V亚洲欧美久久| 亚洲国产精品无码久久SM| 伊人久久大香线蕉综合网站| 亚洲综合婷婷久久| 国产精品久久久久jk制服| 亚洲中文字幕无码一久久区| 天天躁日日躁狠狠久久| 亚洲国产成人精品女人久久久 | 亚洲精品国精品久久99热| 久久久久国产| 欧美成人免费观看久久| 久久精品中文字幕有码| 国产伊人久久| 久久久这里有精品|