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

            常用鏈接

            留言簿(9)

            我參與的團隊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            const 常量函數只能調用其中的常量相關的東西。
            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];
             }
            但是還發現出現錯誤。
            g:\framework\foundation\foundation\core\factory.cpp(60) : error C2678: 二進制“[”: 沒有找到接受“const std::map<_Kty,_Ty,_Pr>”類型的左操作數的運算符(或沒有可接受的轉換)
                    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>
                    ]
                    試圖匹配參數列表“(const std::map<_Kty,_Ty,_Pr>, std::string)”時
                    with
                    [
                        _Kty=std::string,
                        _Ty=Core::Rtti *,
                        _Pr=StringLess
                    ]
            這里主要是const函數的濫用,因為不清楚const函數究竟能對什么進行操作就濫用。
            map的const對象不可以調[]。
            operator[] 不是 const類型。
            所以這個錯誤基本上將const去掉就好了。
            這里總結一些東西,以前也濫用過const的東西
            返回const表示這個返回內容是只讀的,不能被修改的。
            參數使用const表示這個參數是只讀的,而不能進行任何修改,只參與計算,而不修改本身。
            const常函數,只能對常量進行操作,說明在這里主要是進行常量成員的操作,而不做任何與const無關的操作,上面就是個很好的例子。
            posted on 2008-09-03 10:20 jolley 閱讀(1618) 評論(0)  編輯 收藏 引用
            中文字幕亚洲综合久久菠萝蜜| 精品国产乱码久久久久久人妻| 伊人久久无码中文字幕| 久久精品中文騷妇女内射| 国产A级毛片久久久精品毛片| 久久99精品国产99久久6| 99久久久国产精品免费无卡顿| 色综合久久中文字幕综合网| 久久亚洲精品国产亚洲老地址| 新狼窝色AV性久久久久久| 欧美亚洲另类久久综合婷婷| 少妇被又大又粗又爽毛片久久黑人 | 亚洲人成网亚洲欧洲无码久久 | 99蜜桃臀久久久欧美精品网站 | 国产一区二区三精品久久久无广告| 久久人人爽人人爽人人片AV不| 国产精品久久久久9999| 久久久国产精品福利免费 | 国产成人无码精品久久久免费 | 欧美国产成人久久精品| aaa级精品久久久国产片| 久久久久久狠狠丁香| 国产叼嘿久久精品久久| 久久精品国产只有精品66| 欧美久久一区二区三区| 亚洲中文精品久久久久久不卡| 久久国产精品一区二区| 亚洲精品tv久久久久久久久久| 性做久久久久久久| 久久久精品久久久久特色影视| 亚洲狠狠婷婷综合久久久久| 国产精品久久国产精品99盘 | 久久香蕉超碰97国产精品| 欧美麻豆久久久久久中文| 久久国产精品成人免费| 久久精品国产免费观看三人同眠| 久久国产精品99精品国产987| 亚洲国产另类久久久精品小说| 欧美精品丝袜久久久中文字幕| 久久国产免费观看精品| 国产精自产拍久久久久久蜜|