[英]Deleting pointers in non pointer vector
I'll post a screenshot of code because also want to show the variables while debugging. 我将发布代码的屏幕截图,因为它也想在调试时显示变量。 Screenshot: 截图:
Ok, so I have the code as on the screenshot and: 好的,所以我的代码如屏幕截图所示:
SystemClass *pSystemClass = new SystemClass();
// Use of pSystemClas
delete pSystemClass;
And the question, do I have to remove the pointers that are stored in vp_DatabaseManager vector before deleting pSystemClass or can I do it in SystemClass destructor as it is shown on the screenshot? 问题是,在删除pSystemClass之前是否必须删除vp_DatabaseManager向量中存储的指针,还是可以在屏幕截图中显示的SystemClass析构函数中进行操作?
Because in the debug mode it looks like the vp_DatabaseManager vector is deleted before I can access the pointers in SystemClass destructor. 因为在调试模式下,似乎可以删除vp_DatabaseManager向量,然后才能访问SystemClass析构函数中的指针。
In the SystemClass
destructor, iterate through the vector
and delete the pointers. 在SystemClass
析构函数中,迭代vector
并删除指针。 You can also research unique_ptr
. 您还可以研究unique_ptr
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.