Joel Olson
2005-12-11 17:52:25 UTC
For the case of "map< char*, someobject*, ltstr > amap;
where ltstr is used to compare two c strings. If the following code is
executed
...
char* mapkey = new char[ SOMECONST ];
strcpy( mapkey, "akey" );
someobject* someobj = new someobject();
// Initialize someobj
amap[ mapkey ] = someobj;
...
We have to remember that mapkey was used and delete it ourselves
correct? Meaning amap.erase( "akey" ) will only remove the map entry
not the memory for the key or the object held in the map entry, right?
Thanks,
Joel
where ltstr is used to compare two c strings. If the following code is
executed
...
char* mapkey = new char[ SOMECONST ];
strcpy( mapkey, "akey" );
someobject* someobj = new someobject();
// Initialize someobj
amap[ mapkey ] = someobj;
...
We have to remember that mapkey was used and delete it ourselves
correct? Meaning amap.erase( "akey" ) will only remove the map entry
not the memory for the key or the object held in the map entry, right?
Thanks,
Joel