第一种方法:
std::list<Entity *> children;
for(auto&& child : children) {
delete child;
}
children.clear();
第二种方法:
std::list<Entity *> children;
for(auto itr = children.begin(); itr != children.end(); ++itr)
{
Entity* child = *itr;
delete child;
}
第三种方法:
std::list<Entity *> children;
for(Entity *ptr : children) {
delete ptr;
}
children.clear();
时间: 2024-10-06 15:12:07