我在下面的单位代码中做了什么?
当我运行此代码时,表单冻结,没有消息输出。
//---------------------------------------------------------------------------
#include <vcl.h>
#include <map.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btn1Click(TObject *Sender)
{
typedef multimap<AnsiString,int> TMM;
TMM mm1;
mm1.insert(TMM::value_type("Vasya Vasya",1954));
mm1.insert(TMM::value_type("Ivan Petr",1985));
mm1.insert(TMM::value_type("Hasan Husein",1983));
mm1.insert(TMM::value_type("Julia Mck",1982));
AnsiString s="";
TMM::iterator it=mm1.begin();
while (it!=mm1.end())
{
s+=(*it).first+ "-"+ IntToStr((*it).second)+"\n";
}
ShowMessage(s);
}
//---------------------------------------------------------------------------
答案 0 :(得分:2)
你需要增加while循环中的迭代器