howto dispatch to derived classes?
Manfred Nowak
svv1999 at hotmail.com
Mon Oct 14 23:15:18 PDT 2013
=?UTF-8?B?QWxpIMOHZWhyZWxp?= wrote:
> a virtual function like accept() can do the trick
This would require changes in the whole class hierarchy.
But because of
> The actual type of the object is implicitly stored in the
> vtbl of each type.
and in addition, because the statement
| writeln( getC.classinfo.create.classinfo);
gives the correct type there should be a possibility to dispatch to the
correct `visit' function without any changes in the class hierarchy.
I see that a sequence of statements
| if( auto tmp= cast(Ci) getC) visit( tmp);
can dispatch to the correct `visit' function. But this again would
require knowledge of all `Ci'.
A solution seems very close, but ...
-manfred
More information about the Digitalmars-d-learn
mailing list