繁体   English   中英

如何将数据插入 std::map 并在 vc6 中显示来自 std::map 的数据

[英]how to insert data into std::map and show data from std::map in vc6

我正在使用vc6。 下面的代码有什么问题,我找不到:

std::map<int, std::vector<int> > myTemplate; 

//append data to map
int temp=0;
for (int i=0;i<=5;i++)
{
    std::vector<int> tempVector;
    temp+=111;
    tempVector.push_back(temp);
    std::pair<int, std::vector<int> > myPair;
    myPair=std::make_pair(i,tempVector);
    myTemplate.insert(myPair);
}

//show data from map
std::map<int, std::vector<int> >::iterator iter;
iter=myTemplate.begin();
while(iter!=myTemplate.end());
{
    std::vector<int> tempVector;
    std::vector<int>::iterator sencondIter=iter->second.begin();
    int myValue=*sencondIter;
    CString cstrTemp;
    cstrTemp.Format("%d is the int type value in vector<int>",myValue);
    AfxMessageBox(cstrTemp);

    iter++;
}

while后的分号导致无限循环

while(iter!=myTemplate.end()); // <-----------------------

去掉它。

我建议您在此处查看 Microsoft Visual Studio Express: http://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express

对于 MS Visual Studio IDE 的更新版本

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM