在堆上声明一个二维向量
第一种方法:
vector< vector<CString> *> * lstTableContent = new vector< vector<CString> *>();
int nNumColumns = 10;
int nNumRows = 10;
for (int i = 1; i <= nNumRows ; i++)
{
vector<CString> *lstTableRow = new vector<CString>();
for (int j = 1; j <= nNumColumns ; j++)
{
lstTableRow->push_back("ITEM");
}
lstTableContent->push_back(lstTableRow);
}
return lstTableContent;
第二种方法:
vector< vector<CString> > * lstTableContent = new vector< vector<CString> >();
int nNumColumns = 10;
int nNumRows = 10;
for (int i = 1; i <= nNumRows ; i++)
{
vector<CString> lstTableRow;
for (int j = 1; j <= nNumColumns ; j++)
{
lstTableRow.push_back("ITEM");
}
lstTableContent->push_back(lstTableRow);
}
return lstTableContent;
哪种方法是正确的?如何删除二维向量?