typeid() broken for interfaces?

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Sun Dec 2 11:26:36 PST 2012


What's the logic in this behavior?


On Sun, Dec 2, 2012 at 1:28 AM, Walter Bright <newshound2 at digitalmars.com>wrote:

> On 11/30/2012 9:04 PM, Gor Gyolchanyan wrote:
>
>> interface I { }
>> class C: I { }
>>
>> I object = new C;
>> assert(typeid(object) == typeid(C)); // fails
>>
>> Is this normal or is it a bug?
>>
>
> Normal, since the typeids of interfaces are not the same as for classes.
>
>
>  Note, that the same works fine in case of a base class, rather then an
>> interface.
>>
>
> That works, because classes are classes. Classes are not interfaces.
>
>
>
>


-- 
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121202/99957dca/attachment-0001.html>


More information about the Digitalmars-d mailing list