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?<br>
<br><div class="gmail_quote">On Sun, Aug 8, 2010 at 11:57 PM, Andrej Mitrovic <span dir="ltr"><<a href="mailto:andrej.mitrovich@gmail.com">andrej.mitrovich@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
test.d:<br>
<br>
class Contact<br>
{<br>
}<br>
<br>
class Friend : Contact<br>
{<br>
void reminder()<br>
{<br>
writeln("friend.reminder");<br>
}<br>
}<br>
<br>
unittest<br>
{<br>
Contact c = new Friend; // c has type Contact but really refers to a Friend<br>
<br>
writeln(typeid(c));<br>
c.reminder();<br>
}<br>
<br>
This will not compile, as expected, since a Contact type doesn't have the reminder method.<br>
<br>
But if I comment out the c.reminder() line, writeln will return "test.Friend". Why is that?<br>
</blockquote></div><br>