reference to an interface
Ryan Steen
Ryan_member at pathlink.com
Sat Apr 8 07:58:04 PDT 2006
The documentation on interfaces says, that an instance of an interface cannot be
created. But the examples show how to work with an instance of an interface,
although it is reconverted from a class that derives from it. To understand what
this means I wrote this little peace of code and banged my head against a brick
wall.
interface I{
void help();
}
interface J{
void help();
}
class C1:I{
void help(){
printf( "Hello World.");
}
}
class C2: C1, J{
void help(){
printf( "Hello Grave.");
}
}
void f( I i){
i.help();
}
void main(){
f( new C2);
}
In class C2 I have overridden the function help from class C1 and reimplemented
the function help from interface J, didn't I? Why don't I get the function help
from interface I?
Ryan Steen
--
Ask me again, when I am old enough.
More information about the Digitalmars-d-learn
mailing list