The following code adds a new object to a list in a list object and then removes it:
void __fastcall TForm1::Button1Click(TObject *Sender) { TList *pList = new TList(); AnsiString TheObject = "This is an object." try { pList->Add(TheObject); // add AnsiString instance to list MessageDlg("The list has " + IntToStr(pList->Count) + "objects", mtInformation, TMsgDlgButtons() << mbOK, 0); pList->Remove(TheObject); MessageDlg("The list has " + IntToStr(pList->Count) + "objects", mtInformation, TMsgDlgButtons() << mbOK, 0); } __finally { delete pList; } }
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|