Destructor or no destructor ??
-
In MC++ should we always delete the destructor and the implement the Finalize function or we should never do anything? I am still a little confused about if to leave the desctructor or not Experts?!!? :confused: Al
-
In MC++ should we always delete the destructor and the implement the Finalize function or we should never do anything? I am still a little confused about if to leave the desctructor or not Experts?!!? :confused: Al
If it behaves like C# the destructor is treated as a Finalize method.... Wonder what would happen if you define both :) James Simplicity Rules!
-
If it behaves like C# the destructor is treated as a Finalize method.... Wonder what would happen if you define both :) James Simplicity Rules!
The question may also be: What happens if I don't define a destructor what so ever? Al:confused:
-
The question may also be: What happens if I don't define a destructor what so ever? Al:confused:
In a pure managed class it will be GC'd as normal... The destructor is just there to free up any non-managed resources during GC. If you do have unmanaged resources though you are encouraged to implement IDisposable so that they can be returned ASAP. I have no idea what happens when you mix managed/unmanaged together though :confused: I assume you could treat it like another system resource, implementing IDisposable and calling Dispose from the destructor/finalize methods. James Simplicity Rules!
-
In a pure managed class it will be GC'd as normal... The destructor is just there to free up any non-managed resources during GC. If you do have unmanaged resources though you are encouraged to implement IDisposable so that they can be returned ASAP. I have no idea what happens when you mix managed/unmanaged together though :confused: I assume you could treat it like another system resource, implementing IDisposable and calling Dispose from the destructor/finalize methods. James Simplicity Rules!
So, if I don't have any unmanaged code I could just delete the destructor! Great! Thanks James! Al
-
So, if I don't have any unmanaged code I could just delete the destructor! Great! Thanks James! Al
Albert Pascual wrote: So, if I don't have any unmanaged code I could just delete the destructor! Great! That's what it's called Managed C++. Part of the "managed" is about garbage collection. Nish
Check out last week's Code Project posting stats presentation from :- http://www.busterboy.org/codeproject/ Feel free to make your comments.