Maybe you can create a vector of tv_ins and have a loop that passes
Erasing element by element can be rather slow.
Considering that the serial number should probably be a string rather than an int, I would suggest:
Code:
struct tv_in{
std::string serialNum;
std::string tvBrand;
int screenSize;
};
class serialNumIsEqual
{
public:
serialNumIsEqual(const std::string& serialNum) : serialNum_(serialNum) {}
bool operator()(const tv_in& x) const
{
return x.serialNum == serialNum_;
}
private:
std::string serialNum_;
};
Then the actual erasing would be:
Code:
new_tv.erase(
std::remove_if(new_tv.begin(), new_tv.end(), serialNumIsEqual("5432167890")),
new_tv.end());