www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - polymorphism via array

reply tetsuya <tetsuya_member pathlink.com> writes:
dmd 0.105, winXP


cannot use polymorphism via array.

dmd complains..

test.d: function test.foo (Interface []array)
does not match argument types (Class [5])
test.d: cannot implicitly convert expression
classes of type Class [5] to Interface []

to the following code.

<code>
interface Interface {}
class Class : Interface {}
unittest
{
void foo(Interface[] array) {}
Class[5] classes;
foo(classes);
}
</code>

which does work on Java, btw.


tetsuya
Nov 01 2004
parent tetsuya <tetsuya_member pathlink.com> writes:
oops!!

already discussed on
http://www.digitalmars.com/d/archives/16345.html

sorry for repeating

forget it please.


In article <cm52ff$11q3$1 digitaldaemon.com>, tetsuya says...
dmd 0.105, winXP


cannot use polymorphism via array.

dmd complains..

test.d: function test.foo (Interface []array)
does not match argument types (Class [5])
test.d: cannot implicitly convert expression
classes of type Class [5] to Interface []

to the following code.

<code>
interface Interface {}
class Class : Interface {}
unittest
{
void foo(Interface[] array) {}
Class[5] classes;
foo(classes);
}
</code>

which does work on Java, btw.


tetsuya
Nov 01 2004