随笔 - 505  文章 - 1034  trackbacks - 0
<2007年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678


子曾经曰过:编程无他,唯手熟尔!

常用链接

留言簿(94)

随笔分类(649)

随笔档案(505)

相册

BCB

Crytek

  • crymod
  • Crytek's Offical Modding Portal

Game Industry

OGRE

other

Programmers

Qt

WOW Stuff

搜索

  •  

积分与排名

  • 积分 - 894811
  • 排名 - 14

最新随笔

最新评论

阅读排行榜

评论排行榜

下面代码在vc7.1都不能编译通过,不知道bcb6能不能?

#include <hash_map>

struct stUpdateItem
{
    std::
string _strPath;
    
bool _bDownloadSucceeded;

    stUpdateItem(
const std::string& path) 
        : _bDownloadSucceeded(
false)
        , _strPath(path)
    {
    }
};

typedef std::hash_map
<std::string, stUpdateItem> tUpdateItems;

void ChangeValue(bool* pDownloadSucceeded )
{
    
if (pDownloadSucceeded)
    {
        
*pDownloadSucceeded = true;
    }
}

void ProcessPackFile(stUpdateItem& item)
{
    ChangeValue(
&(item._bDownloadSucceeded));
}

int _tmain(int argc, _TCHAR* argv[])
{
    stUpdateItem item1(
"data\\model.pak");
    stUpdateItem item2(
"date\\texture.pak");
    
    tUpdateItems items;

    items.insert(tUpdateItems::value_type(item1._strPath, item1));
    items.insert(tUpdateItems::value_type(item2._strPath, item2));

    
for (tUpdateItems::const_iterator it = items.begin(); it != items.end(); ++it)
    {
        ProcessPackFile(it
->second);
    }
    
return 0;
}
vc7.1 编译错误:
f:\Practise\Practise_2003\hash_map_const_iterator_test\hash_map_const_iterator_test.cpp(46) : error C2664: “ProcessPackFile” : 不能将参数 1 从“const stUpdateItem”转换为“stUpdateItem &
        转换丢失限定符

posted on 2007-11-01 17:26 七星重剑 阅读(2041) 评论(2)  编辑 收藏 引用 所属分类: PL--c/c++

FeedBack:
# re: 用std::hash_map的const_iterator改变元素second的值会怎样?  2007-11-02 23:36 eray
都是const了,不让修改应该是正常的吧?  回复  更多评论
  
# re: 用std::hash_map的const_iterator改变元素second的值会怎样?  2007-11-03 15:16 重剑
@eray
嗯,是的。好像bcb下就能编译通过。还没测试  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理