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


            久久综合一区二区无码| 国产一区二区三区久久精品| 久久人人爽人人爽人人片AV高清| 久久久久亚洲AV无码专区首JN | 久久久久波多野结衣高潮| 亚洲国产精品无码久久久蜜芽| 丁香五月网久久综合| 2021国产精品久久精品| 99久久无码一区人妻| 色婷婷综合久久久久中文一区二区| 麻豆精品久久精品色综合| 麻豆精品久久久久久久99蜜桃| 麻豆精品久久久一区二区| 97精品国产97久久久久久免费| 久久人人爽人人爽人人片AV东京热| 97久久精品午夜一区二区| 热99RE久久精品这里都是精品免费| 国产精品久久久久天天影视| 久久伊人精品一区二区三区| 久久婷婷五月综合色99啪ak| 日本一区精品久久久久影院| 精品久久久无码人妻中文字幕豆芽| 久久这里只有精品首页| 久久久久亚洲国产| 亚洲精品97久久中文字幕无码| 国内精品欧美久久精品| 久久成人精品| 久久97久久97精品免视看| 国产精品99久久久久久宅男| 久久精品国产亚洲网站| 国内精品久久久久影院一蜜桃| 伊人久久无码中文字幕| 亚洲午夜久久久久久久久电影网| 久久91精品国产91| 欧美黑人激情性久久| 亚洲午夜久久久久妓女影院 | 色综合久久综合网观看| 国产高潮国产高潮久久久91 | 亚洲一区二区三区日本久久九| 精品久久久久久久| 久久久久女教师免费一区|