I found the code will not call the destructor of A("object1") who's memory had been overed by another A object. and If A has dynamic memory, memory leak happens.
what's more,
1 2 3 4
{
vector<vector<int>> a = {vector<int>({1,2,3}), vector<int>({4,5,6})};
a[0] = vector<int>({7,8,9});
}
for this code , suppose vector has dynamic memory, then the memory of vector<int>{1,2,3} will leak, cause vector<vector<int>> will not call destructor of vector<int> just like last example.
My question is :
Why the memory leak happens so easy? Do i fall into some error?
here is the code of A
and output of the first example