关于hash_map的使用
我想在BCB下用hash_map来实现一个翻译的功能,写了如下的程序:
#include <vcl.h>
#include <map>
#include "stlport\hash_map"
using namespace std;
#pragma hdrstop
typedef hash_map<String, String > Months;
typedef pair<String, String> String_Pair;
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Months monthdays;
monthdays.insert(String_Pair("jan", "janvier"));
monthdays.insert(String_Pair("fev", "febrery"));
// Go through all the items in the list
Months::iterator mon;
AnsiString s;
for (mon = monthdays.begin(); mon != monthdays.end(); mon++)
{
s = (*mon).first + " est " + (*mon).second;
ListBox1->Items->Add(s);
}
}
//---------------------------------------------------------------------------
编译的时候老是通不过,请各位帮忙看一下,有什么办法解决。