Write your question here.
Hi guys. I am working on an assignment and I only have to convert a shared pointer to an object to finish it. I am not supposed the change the parameter in these code. I just want to convert my shared_pointer spec to a TownSpec object.
void Inventory::add_city(std::string const& name, std::shared_ptr<const TownSpec> spec)
{
Town new_city(name, spec);
Town& i = find_city(spec); //check if the city already exists but takes
//as parameter a TownSpec object
if (i.get_name() != name)
{
_cities[_count] = new_city;
_count++;
}
}
Town Inventory::find_city(const TownSpec& otherSpec) const//returns just one city
{
for (size_t i(0); i < _count; i++)
{
if (!(_cities[i].get_specification()->matches(otherSpec)))
continue;
return _cities[i];
}
return Town();
}