TList返回值的问题
结构定义,如下
struct TCList { AnsiString y; AnsiString e; }; typedef TCList* Mlist;
TList * TForm16::getDC(AnsiString m1){ Mlist m_dc ; /* m_m为TStringList,此处代码省略 */ dcs = new TList(); dcs->Clear(); for(int i = 0; i < m_m->Count ; i++) { str = m_m->operator [](i); m_dc = new TCList; for(int j = 1 ; j <= str.Length(); j++) { if(j <= 5) { m_dc->y += str[j]; } if(j > 5 && j <= 8 ) { m_dc->e += str[j]; } } dcs->Add(m_dc); delete m_dc; } return dcs;}
TList *xx = this->getDC(m1);
Mlist stu ; for(int i = 0 ; i < xx->Count; i++) { try { stu = (Mlist)xx->Items[i]; AnsiString s = stu->y; //报错 } catch(Exception &e) { Application->MessageBoxA(e.Message.c_str(),"错误提示 :",MB_OK+16); } }