I'm trying to access second element in my mainRegister map:
class Manager
{
private:
std::map<boost::uuids::uuid, Rental*> mainRegister;
std::vector <Rental*> archiveRegister;
std::vector<Client*> ClientRegister;
std::vector<Vehicle*> VehicleRegister;
public:
Manager();
void createRental();
void deleteRental(Rental rent);
std::string showArchive() const;
std::string showMain() const;
std::string showVehicles() const;
std::string showClients() const;
void sortDate();
void sortClient();
bool checkVehicle(std::map <Vehicle*, Rental*> myMap);
virtual ~Manager();
protected:
};
Here is what I'm trying to do:
void Manager::deleteRental(Rental* rent)
{
for (auto it = mainRegister.cbegin(); it != mainRegister.cend()
{
if (it.second->getUUID() == rent->getUUID())
{
archiveRegister.push_back(it.second);
mainRegister.erase(it++);
}
else
{
++it;
}
}
}
My main goal is to find element in map, which second element has the same UUID as the object which is passed to method, and then move that object to archive register vector, and afterwards remove that element from the map.
The errors which I'm getting are :
-struct std::_Rb_tree_const_iterator >' has no member named 'second'|
-no matching function for call to' std::vector::push_back(second_t >)'|
I know that probably the way I'm trying to access the second element of each pair in map is totally wrong, but I don't really know how that could be done .
Aucun commentaire:
Enregistrer un commentaire