I need to be a little patient. :) On the next page it explains the static
vs. dynamic type, so I guess typeid() always returns the dynamic type. I
wonder if there's a way to get the static type, is there an equivalent
function like typeid() for such a case?

On Sun, Aug 8, 2010 at 11:57 PM, Andrej Mitrovic <[email protected]
> wrote:

> test.d:
>
> class Contact
> {
> }
>
> class Friend : Contact
> {
>    void reminder()
>    {
>        writeln("friend.reminder");
>    }
> }
>
> unittest
> {
>    Contact c = new Friend; // c has type Contact but really refers to a
> Friend
>
>    writeln(typeid(c));
>    c.reminder();
> }
>
> This will not compile, as expected, since a Contact type doesn't have the
> reminder method.
>
> But if I comment out the c.reminder() line, writeln will return
> "test.Friend". Why is that?
>

Reply via email to