div0 at users.sourceforge.net
Sat Mar 6 11:02:34 PST 2010
-----BEGIN PGP SIGNED MESSAGE-----
>> Cast the instance to the base class and call the method?
> Surprisingly this does compile.
> What are the rules for casting between classes?
I don't think there are any rules as such.
Casting in D is not well specified.
Between classes you'll probably get a dynamic cast
which happens at run time and a dynamic cast can return
a null reference, so you'll get a crash if you don't guard
You can force a reinterpret cast by casting to void* and
then casting again, but you have to be careful doing that
as you are deliberately subverting type checking.
My enormous talent is exceeded only by my outrageous laziness.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-learn