Does the following code fragment leak? If not, where do the two objects which are constructed in foobar() get destructed?
class B
{
int* mpI;
public:
B() { mpI = new int; }
~B() { delete mpI; }
};
void foobar()
{
B b;
b = B(); // causes construction
b = B(); // causes construction
}
The default copy assignment operator does a member-wise copy.
So in your case:
See Item 11 in Effective C++, 2nd Edition for more details.