小编Ggb*_*oi 的帖子

C++删除向量中的元素

int main(){     

vector<Customer*> newcustomer;

newcustomer.push_back(new Customer("III", 123333, 555));
newcustomer.push_back(new Customer("LOL", 122222, 444));
newcustomer.push_back(new Customer("PPL", 121111, 333));

for (int i = 0; i < 3; i++){
    cout << newcustomer[i]->getName() << endl;
    cout << newcustomer[i]->getPhone() << endl;
    cout << newcustomer[i]->getID() << endl;
    cout << endl;
}






system("pause");
return 0;

}
Run Code Online (Sandbox Code Playgroud)

所以我创建了一个名为customer的类,你可以插入新客户,getName返回名称,getPhone返回电话号码,GetID返回ID,现在我想从该向量中删除所有内容,不知道该怎么做.

c++ vector

4
推荐指数
2
解决办法
186
查看次数

标签 统计

c++ ×1

vector ×1