interface problem
div0
div0 at users.sourceforge.net
Sat Mar 6 11:02:34 PST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Trass3r wrote:
>> 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
against it.
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.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFLkqbKT9LetA9XoXwRAiTtAJ9STEAd+nQxf9URIV+X9HTwLr6TJACfaGoi
fTrzOMyeQNbH95gsj+4sNTU=
=eYEH
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-learn
mailing list