考虑这段代码:
#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()
吗?