The destructor is called 3 times (from only 2 objects!), but I can access the objects in the vector and display the object names, before the destuctor is called 2 more times when the vector goes out of scope (end of program).
My real question is, how do I ensure that the memory allocated by the constructor(s) is properly released?
In createCommon, you're creating two local objects, Com01 and Com02.
Then, when you push them onto your vector, a copy of each of those is created on the vector.
Since you haven't defined a copy constructor for Dish, those copies are shallow copies. This means that indkoeb in Com01 is pointing to the same memory as the copy of it in the first element of the vector.
When createCommon exits, Com01 falls out of scope and is destroyed, and the memory pointed to by Com01.indkoeb is freed by the destructor. This means that that the memory pointed to by Common[0].indkoeb is now pointing at memory which has been freed. This is what causes your crash.
If you want to create copies of your Dish objects, you need to write a copy constructor for the class, that allocates new memory for indkoeb in the copy.
"If you implement one, you usually have to implement all three."
Copy constructor. It is called, when you push_back. You did not implement it, so the compiler did, but that default implementation does not allocate memory dynamically. It just copies values.
After first push_back in createCommon() both Com01.indkoeb and Common.at(0).indkoeb point to same memory. On return from createCommon() the Com01 is destroyed. After that the Common.at(0).indkoeb still points to memory that has already been released.
Vector has capacity. You start with empty vector, so possibly:
// size==0, capacity==0
push_back(A)
allocate space1 for one
copy A to space1
// size==1, capacity==1
push_back(B)
allocate space2 for two
copy one value from space1 to space2
copy B to space2
deallocate space1 ** This is where the first destructor would fire
// size==2, capacity==2
return from function
two local variables self-destruct
return from main()
vector deallocates space2 and destroys the two objects in it
You could verify that by adding debug prints here and there, testing effect of vector::reserve() and different number of push_back()s.