Re: Problem with linker
"MrAsm" <mrasm@usa.com> wrote in message
news:087g63971kmhdfjeol85dcd9p2sg8f7c0q@4ax.com...
But would 'using' C# keyword be useful here?
Yes, both the C# "using" statement and C++/CLI RAII pattern (C++ style where
dtor is supposed to free unmanaged resources) more or less cures this. But
reading the fine points, it seems that implementing a class that supports
IDisposable gets a little difficult. The IDisposable::Dispose() method has
a flag that you need to check and do different things, and because it can be
called more than once, you have to cache whether you've disposed previously.
Then you have to call GC::SuppressFinalize(). It's not very straightforward
and very error prone.
I'm not an expert, but there seem to be all kinds of corner cases that just
don't exist in C++ dtors. Things such as any owned classes embedded within
your class also need to support IDisposable. I don't know about you, but I
don't want to be limited in what classes I can have in my class, if I want
my class to support IDisposable!
But I'm not sure how much these corner cases really affect life for real.
Maybe you can just forget about it. I'm hoping so.
-- David