I have the following setup:
interface A {
...
}
interface B {
A foo ();
}
class C : A {
...
}
class D : B {
C foo ();
}
So basically, I want class D to return a specific type (C) while at the same time implementing interface B which wants a more general type returned (A). One would think that since C implements A, returning C would be just fine when A is asked for.
I am 100% sure that this could be done by the compiler, if only Microsoft would check the inheritance tree to make sure that C was an A. Anyone have any ideas about how to make it work without getting Microsoft to do a rewrite?
"Programming is like sex, one mistake and you have to support it forever."
John
johnmc@mvmills.com
interface A {
...
}
interface B {
A foo ();
}
class C : A {
...
}
class D : B {
C foo ();
}
So basically, I want class D to return a specific type (C) while at the same time implementing interface B which wants a more general type returned (A). One would think that since C implements A, returning C would be just fine when A is asked for.
I am 100% sure that this could be done by the compiler, if only Microsoft would check the inheritance tree to make sure that C was an A. Anyone have any ideas about how to make it work without getting Microsoft to do a rewrite?
"Programming is like sex, one mistake and you have to support it forever."
John
johnmc@mvmills.com