Assigning Interface to Object
Simen kjaeraas
simen.kjaras at gmail.com
Sat Jan 15 08:41:10 PST 2011
Trass3r <un at known.com> wrote:
>> module testObj;
>>
>> public interface testInterface {
>> void someMethod();
>> }
>> public class testObj
>> {
>> Object someCaller;
>> this(Object caller) {
>> someCaller = caller;
>> }
>> this(testInterface tI, bool xyz) {
>> someCaller = tI;
>> }
>> }
>>
>> Shouldn't this work?
>
> Doesn't really make sense.
> If you cast it to Object you "loose" the interface methods.
Same way you lose methods of a subclass when you cast it to
a base class. That's allowed, though.
--
Simen
More information about the Digitalmars-d-learn
mailing list