开发者

const_iterator Prolems

I've never used const_iterator before and am having difficulty getting this to debug. Any help is appreciated. Windows 7 and开发者_开发技巧 VS 2010 Thank you.

typedef std::basic_string <unsigned char> ustring;
ustring receivedData(data[i], length);
typedef std::map<string, int> MapMime;
MapMime mymap;

mymap["audio/basic"] = 1;
mymap["audio/x-aiff"] = 2;
mymap["audio/x-wav"] = 3;
mymap["video/mpeg"] = 4;
mymap["video/mpeg-2"] = 5;
mymap["video/quicktime"] = 6;

for (MapMime::const_iterator it = mymap.begin(), itEnd = mymap.end();it !=   itEnd.++it);
{
size_t findPosition = receivedData.find(it->first);
if (findPosition != string::npos)
    {
    // Found a match at position findPosition
    }
    else
    {
    // That MIME type was not found in the data...
    }
}


You have an extra semicolon after the for loop, you should remove it. Otherwise, 'it' is defined only inside the for loop, which is empty.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜