I think I see what is going on here:
In your TestSet Class you have a
vector <testRun>
variable
and a function
1 2 3 4 5
|
bool TestSet::addRun(TestRun &tr)
{
testRuns.push_back(tr);
return true;
}
|
The vector has initial size of 0 (zero) elements so each time you do the push.back the vector has to reallocate space for it, which means that it creates a new vector space, copies the elements from the old space and has to destroy the previous copies which means that the destructor gets called for each TestRun variable.
This explains why you get that strange pattern of TestRun destructor calls
for example when the first testRun is added there are no previous ones to delete.
When the second one is added the old copy of the first one is destructed.
(one destructor call)
when the third one is added , old copies of the previous two are destructed
(two destructor calls).
as so it goes on.
The way around this is to maybe reserve some intial vector space say enough for 10 (ten) testRuns like this:
1 2 3 4 5 6 7 8
|
TestSet::TestSet()
{
// some stuff goes here
testRuns.reserve(10); //initial space allocation for 10 testRuns
cout << "TestSet constructor\n";
}
|
and you will see a difference.