Let's say I have a struct defined as so:
struct Barre {
int startString;
int endString;
Barre() { startString = endString = -1; }
Barre(int s, int e) : startString(s), endString(e) {}
bool exists() { return startString > -1; }
};
I will create an instance of this struct like this, for example:
Barre b = Barre(2, 4);
Let's say I insert this into a std::map<int, Barre>
which is a member of a class, with a key of, for example, 3.
If I then create another Barre as above and overwrite the value of the map at key 3 with this new instance of the Barre struct, do I need to explicitly delete
the old Barre object that I'm overwriting to prevent memory leaks? Or does it not persist once it is no longer stored in a map in this way?
Thanks for any help.