我正在努力从一个向量中删除一个自定义类型。我有以下代码:
#include "pch.h"
#include <iostream>
#include <vector>
class Account {
public:
std::string name;
int balance;
};
int main()
{
std::vector<Account> holding_vector;
Account new_acc1;
Account new_acc2;
Account new_acc3;
holding_vector.push_back(new_acc1);
holding_vector.push_back(new_acc2);
holding_vector.push_back(new_acc3);
}
我该如何删除new_acc2
呢?唯一能想到的实际想法是尝试并覆盖类的一个运算符,以便find()
算法可以在矢量中定位对象。
https://stackoverflow.com/questions/55446018
复制相似问题