考虑以下代码:
#include <vector>
void Example()
{
std::vector<TCHAR*> list;
TCHAR* pLine = new TCHAR[20];
list.push_back(pLine);
list.clear(); // is delete called here?
// is delete pLine; necessary?
}
list.clear()
是否会调用每个元素的delete
函数?也就是说,在/之后调用list.clear()
之前,我是否需要释放内存?