簡體   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