【发布时间】:2019-05-29 09:26:21
【问题描述】:
如何删除下面这个sn-p中创建的动态对象数组?
我试图在论坛中浏览一些以前的答案,但没有人可以为我指出答案。
#include <iostream>
struct Card{int x;};
int main()
{
std::vector<Card*> S;
for (int i = 0; i < 3; i++)
{
Card* o = new Card;
o->x = i;
S.push_back(o);
}
for (auto a : S)
std::cout << "Opening from the container " << a->x << '\n';
//delete o; --------> How to delete the array of objects???
return 0;
}
【问题讨论】:
标签: c++ visual-c++