G
Guest
All -
As we all know, Dispose method is reserved in C++ 8 and the expected syntax
is to use ~MyClass().
In 1.1, we used to have following structure for Dispose
[Code illustrated in C# for brevity]
class MyClass : IDisposable
{
public void Dispose() { Dispose(true); GC.Supressxxx(this); }
~Dispose() { Dispose(false); } // Finalizer
protected virtual void Dispose(bool disposing)
{
if(disposing) { xxx } // Disposing ilustrates if we are in finalizer
yyyy
}
}
System.Windows.Forms.Form used to have such a model, and we used it for our
finalizable classes to implement all cleanups in the single "protected
override Dispose(bool disposing)", which nicely has the "disposing" parameter.
Now C++ 8.0, disallows having any function by name Dispose and the structure
has to be changed with a new name (protected virtual "DisposeObject" for
instance)
The question is -
Why does the compiler forbids even overloaded Dispose [like Dispose(bool)]
methods. I can understand the reserved method for Dispose() but why for
overloads even?
If we simply re-compile our code with the new compiler (after syntax
changes), it we will break our clients. Clients will have to change their
code for overriding the Dispose method!
Any suggestions? [Using VS 2005 Beta 2]
Thanks in advance.
Regardz
Grafix.
As we all know, Dispose method is reserved in C++ 8 and the expected syntax
is to use ~MyClass().
In 1.1, we used to have following structure for Dispose
[Code illustrated in C# for brevity]
class MyClass : IDisposable
{
public void Dispose() { Dispose(true); GC.Supressxxx(this); }
~Dispose() { Dispose(false); } // Finalizer
protected virtual void Dispose(bool disposing)
{
if(disposing) { xxx } // Disposing ilustrates if we are in finalizer
yyyy
}
}
System.Windows.Forms.Form used to have such a model, and we used it for our
finalizable classes to implement all cleanups in the single "protected
override Dispose(bool disposing)", which nicely has the "disposing" parameter.
Now C++ 8.0, disallows having any function by name Dispose and the structure
has to be changed with a new name (protected virtual "DisposeObject" for
instance)
The question is -
Why does the compiler forbids even overloaded Dispose [like Dispose(bool)]
methods. I can understand the reserved method for Dispose() but why for
overloads even?
If we simply re-compile our code with the new compiler (after syntax
changes), it we will break our clients. Clients will have to change their
code for overriding the Dispose method!
Any suggestions? [Using VS 2005 Beta 2]
Thanks in advance.
Regardz
Grafix.