I’m having problems with this call:
m_baseMap.find(baseName)->second->AddVehicale(vehicaleToAdd);
There’s a red line under m_baseMap, the error is : “the object has type qualifiers that are not compatible with the member function”. The base map is defined as the following:
map <string, const Base*> m_baseMap;
How can I fix it?
The issue is not with the
find()but with the call AddVehicale because the map specifiesconst Base*. You either need to make themapbemap<string, Base *>or make sureAddVehicaleis a const method (which means you are promising not to modify the object pointed to in the map) e.g.void Base::AddVehicale(Vehicale &v) const;As far as I know, the compiler will choose whether to use the const find or the non-const find based on whether the map itself is const at the time (like if you have a const reference to the map)
P.S. Vehicale is spelled Vehicle (I use google to spell check if I’m not sure, search for the word and it will suggest the correct spelling)