SubClass[] does not implicitly convert to SuperClass[], why?

Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 19 23:57:16 PST 2015


What's the reason behind this design?

class Super {}
class Sub : Super {}

void foo(Super[] sup) {}

void main() {
     Sub[] array;
     foo(array); // error, cannot call foo(Super[]) with arguments 
(Sub[])
}


More information about the Digitalmars-d-learn mailing list