#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 編譯錯誤: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;
}
f:\Practise\Practise_2003\hash_map_const_iterator_test\hash_map_const_iterator_test.cpp(46) : error C2664: “ProcessPackFile” : 不能將參數 1 從“const stUpdateItem”轉換為“stUpdateItem &”
轉換丟失限定符
轉換丟失限定符