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

            常用鏈接

            留言簿(9)

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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            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)制“[”: 沒有找到接受“const std::map<_Kty,_Ty,_Pr>”類型的左操作數(shù)的運(yùn)算符(或沒有可接受的轉(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ù)究竟能對什么進(jìn)行操作就濫用。
            map的const對象不可以調(diào)[]。
            operator[] 不是 const類型。
            所以這個(gè)錯(cuò)誤基本上將const去掉就好了。
            這里總結(jié)一些東西,以前也濫用過const的東西
            返回const表示這個(gè)返回內(nèi)容是只讀的,不能被修改的。
            參數(shù)使用const表示這個(gè)參數(shù)是只讀的,而不能進(jìn)行任何修改,只參與計(jì)算,而不修改本身。
            const常函數(shù),只能對常量進(jìn)行操作,說明在這里主要是進(jìn)行常量成員的操作,而不做任何與const無關(guān)的操作,上面就是個(gè)很好的例子。
            posted on 2008-09-03 10:20 jolley 閱讀(1618) 評論(0)  編輯 收藏 引用

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


            久久免费精品一区二区| 久久亚洲精品人成综合网| 精品国产91久久久久久久a| 色播久久人人爽人人爽人人片aV| 亚洲欧美成人久久综合中文网 | 99久久婷婷免费国产综合精品| 久久夜色精品国产亚洲| 一本久久综合亚洲鲁鲁五月天| 国产精品久久久亚洲| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 久久国产精品波多野结衣AV| 伊人久久大香线蕉亚洲五月天| 久久亚洲精精品中文字幕| 久久国产午夜精品一区二区三区| 久久综合综合久久综合| 欧美精品丝袜久久久中文字幕 | 亚洲国产成人久久综合区| 久久精品九九亚洲精品天堂| 久久天天婷婷五月俺也去| 日本久久久精品中文字幕| 久久久久亚洲精品天堂| 久久99热这里只有精品66| 久久99国产精品成人欧美| 国产成人精品白浆久久69| 亚洲狠狠婷婷综合久久蜜芽| 99久久这里只精品国产免费| 国产精品日韩深夜福利久久| 91精品日韩人妻无码久久不卡| 精品国际久久久久999波多野| 亚洲精品乱码久久久久久按摩| 欧美国产成人久久精品| 亚洲精品无码久久毛片| 精品久久久久久无码不卡| 久久亚洲精品无码VA大香大香| 免费一级做a爰片久久毛片潮| 国产精久久一区二区三区| 久久se这里只有精品| 亚洲欧美国产日韩综合久久| 日本五月天婷久久网站| 亚洲精品乱码久久久久久中文字幕| 亚洲精品国精品久久99热一|