Differing implementations for a function in two interfaces
Lionello Lunesu
lio at lunesu.remove.com
Mon Apr 17 01:59:59 PDT 2006
Ryan Steen wrote:
> In article <e1vbp8$1lcq$1 at digitaldaemon.com>, Lionello Lunesu says...
>
>> So the problem in the original post still applies to opIndex and opCall.
>
> Only if the formal parameter lists stay the same. Is it a good design not to
> have typedef'ed subtypes for fieldnames and parameternames, rowindex and
> columnindex?
>
>
Nice idea!
#typedef uint field_no;
#typedef uint param_no;
#interface IA {
# char[] opIndex(param_no);
#}
#interface IB {
# char[] opIndex(field_no);
#}
#class C : IA, IB {
# char[] opIndex(param_no p) { return "param"; }
# char[] opIndex(field_no p) { return "field"; }
#}
#void main() {
# C c = new C;
# IA ia = cast(IA)c;
# writefln( "ia[2]=",ia[2]);
# IB ib = cast(IB)c;
# writefln( "ib[2]=",ib[2]);
#}
Excellent, really... I think I'm in love...
L.
More information about the Digitalmars-d-learn
mailing list