How to find whether an element exists in std::map?
return cars.find(name) != cars.end();
Sure, use an iterator
map<string,Car>::const_iterator it = cars.find(name);
return it!=cars.end();
You could also use
bool exists(const string& name) {
return cars.count(name) != 0;
}