for(int i = 0; i< list->Count;i++)
{
delete(Data*)list->Items[i];
}
list->Clear();
delete를 모두 하고 나서 Clear 해야 합니다.
gksqjs94 님이 쓰신 글 :
: class Data
: {
: public:
: String combo1;
: String combo2;
: }
:
:
: void __fastcall TFrmAddData::AddClick(TObject *Sender)
:
: Data* data= new Data();
: data->combo1 = cbCombo1->Text;
: data->combo2 = cbCombo2->Text;
: list->Add(data);
:
: void __fastcall TFrmAddData::Refresh()
: {
: for(int i = 0 ; i< list->count; i++)
: {
: Data* data = list[i];
:
: StringGird1->Cells[1][i+1] = data -> combo1;
: StringGird1->Cells[2][i+1] = data -> combo2;
: }
: }
:
: 이런식으로 리스트에 객체를 넣는다고하면
:
: for(int i = 0; i< list->Count;i++)
: {
: delete(Data*)list->Items[i];
: list->Clear();
: }
: 위와 같은식으로하면 메모리해제 완벽히 될까요 ?
: 답변부탁드립니다.
:
: ps: 추가질문이요.. 지금보니까 TStringLsit 는 SaveToFile 이 있는데 TList는 없네요..?
: TList에 있던거 txt파일로 만들려면 String에다가 다 넣어넣고 써내야할까요 ?
:
:
:
:
|