R
Robert
I'm reading the book "Programming .NET Components" by Juval Lowy, a renowned
..NET expert as recognized by MSFT. In the book he provides a base class
example that implements a pattern for safely cleaning up your objects
(handling "IDisposable", etc.). His class calls a (do-nothing) virtual
"Cleanup()" function from its destructor however (we're supposed to override
it) and I'd like to confirm that this is in fact safe. Presumably it is but
it's not in C++ for good reason (since objects are destroyed from the
bottom-up). This would make sense in any language but I've read elsewhere
that virtual methods aren't illegal in C# constructors (though their safety
is another matter). Can anyone comment on this situation in particular. Is
it safe to call a virtual "Cleanup()" function from a base class destructor.
Thanks.
..NET expert as recognized by MSFT. In the book he provides a base class
example that implements a pattern for safely cleaning up your objects
(handling "IDisposable", etc.). His class calls a (do-nothing) virtual
"Cleanup()" function from its destructor however (we're supposed to override
it) and I'd like to confirm that this is in fact safe. Presumably it is but
it's not in C++ for good reason (since objects are destroyed from the
bottom-up). This would make sense in any language but I've read elsewhere
that virtual methods aren't illegal in C# constructors (though their safety
is another matter). Can anyone comment on this situation in particular. Is
it safe to call a virtual "Cleanup()" function from a base class destructor.
Thanks.