I am wondering if I should delete any secondary object in the destructor of the primary object.
Example: In a Unit operation implementing COBIA, "Unit" is the primary unit operation class with a few basic secondary objects. In "Unit.h", I tried using the following destructor:
Code: Select all
~Unit() {
delete(param);
delete(paramCollection);
delete(product);
delete(feed);
delete(portCollection);
}
While debugging I noticed a few calls to the destructor while calculating and ended up with an exception thrown for too many calls to release, so I removed all the delete statements and everything went well. I am curious to know why this happened. I thought the destructor would be called only when I delete the unit from my flowsheet.
Thanks in advance.