reimplementing an interface in a derived class
bauss
jj_1337 at live.dk
Fri Jan 4 09:58:59 UTC 2019
On Friday, 4 January 2019 at 09:53:18 UTC, Alex wrote:
> I assume the move method of an Animal is not abstract, and
> therefore I supposed, casting to this type explicitly should
> restore this very non-abstract behavior. But this is not the
> case.
> And the final/virtual thing above explains this to some extent,
> too... I think...
A cast is only a way to tell the compiler the signature of a type.
In most cases it actually does nothing at runtime and is just a
way to help the compiler.
Ex.
auto b = new B;
auto a = cast(A)b;
Will just tell the compiler that all usage of a will be
restricted to the signature of A.
It doesn't tell the compiler that all usage of a should be the
same as A.
At runtime it would actually just be:
auto b = new B;
auto a = b;
More information about the Digitalmars-d-learn
mailing list