map<string, a> myMap; .... myMap = new map<string, a>;
Here myMap
not a pointer, so initialization with new
is incorrect. You may be looking for:
myMap = map<string,a>();
to copy the myMap
initialized map to myMap
.
Note that you do not need (and actually cannot) delete myMap
, as it is not a pointer. This is a member variable, and the compiler will take care of automatically destroying it when your class is destroyed.
source share