There are no overload of std::map::insert
that takes a key and a value.
You can use operator[]
to add a new element:
mp[key] = *obj;
Or std::map::insert_or_assign
since C++17:
mp.insert_or_assign(key, *obj);
Another point is that type of obj
is test*
while the type of values of the map mp
has type test
. The pointer should be dereferenced (like my examples above) or the type of values should be changed to pointers to do this insertion.
CLICK HERE to find out more related problems solutions.