Is it a good practice to call a function inside a destructor which does some memory allocations internally. Because this is giving me access violations and other issues, For suppose
~Example(){
Stop();
}
Here in this function Stop() does various things and also calls various other functions? Is it a good practice. Can anyone help with this?
There is nothing wrong in calling functions inside destructor the only important point to consider is that there should be no uncaught exceptions emitting from a destructor.
So, As long as you catch all the exceptions thrown from functions called within the destructor inside the desructor, You are safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With