I am porting some old code from C to C ++. The old code uses object-like semantics and at some point separates the destruction of the object from the release of unused memory, and the material happens between them:
Object_Destructor(Object *me) { free(me->member1), free(me->member2) }
ObjectManager_FreeObject(ObjectManager *me, Object *obj) { free(obj) }
Is the above functionality possible in C ++ using a standard destructor ( ~Object) and subsequent call delete obj? Or, as I fear, can this cause the destructor twice?
In the particular case, operator deleteof is Objectalso redefined. Is the definition that I read elsewhere ("when the delete operator is used, and the object has a destructor, the destructor is always called) correctly in the redefined case of the operator?
MaxVT source
share