Does std::vector.clear() do delete (free memory) on each element?

后端 未结 6 665
梦谈多话
梦谈多话 2020-12-04 08:14

Consider this code:

#include 

void Example()
{
    std::vector list;
    TCHAR* pLine = new TCHAR[20];
    list.push_back(pLine)         


        
6条回答
  •  既然无缘
    2020-12-04 08:56

    You might also be able to use the Boost Pointer Container Library. Not specifically recommended here (again because you're using arrays instead of single objects, though std::string would take care of that), but it's a useful and little-known library that solves the problem stated in the title.

提交回复
热议问题