假设我有一个指向“ Order
”对象的指针向量。现在我想从这个向量中删除一个订单。我想知道以下是否是删除此类指针的正确方法?
std::vector<Order*> orders;
// somehow I obtained a vector of Order*, and an iterator it that points to
// an order that I want to remove completely.
// does the following work?
Order *order = *it;
orders.erase(it);
delete order;