2011-08-16 8 views
0

私はvc6を使用しています。std :: mapにデータを挿入し、vc6のstd :: mapのデータを表示する方法

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++; 
} 
+1

それは標準に準拠していないのですのVisual C++ 6を使用しないでください。マイクロソフト社の標準でもない – wilhelmtell

+2

それは本当ですが、それはまだMSがリリースした最高のIDEです。以後リリースされたすべてのバージョンは劣っています。 – john

+0

真剣に、最高のIDEについてのこのナンセンスはどこから来ていますか? – wilx

答えて

8

セミコロンを無限ループでwhile結果

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

はそれを削除した後:私は見つけるカント、以下のコードで何が間違っています。

+0

よく見つかった:-) –

関連する問題