Differing implementations for a function in two interfaces

Ryan Steen Ryan_member at pathlink.com
Sat Apr 15 03:21:20 PDT 2006


In article <e1qem7$1lvs$1 at digitaldaemon.com>, Lionello Lunesu says...

>#class Command : IResult, IResultRow {	// handle wrapper
>#	sqlite3_stmt* stmt;
>#	~this() { sqlite3_finalize(stmt); }
>#	IResult Execute() { return cast(IResult)this; }
>#	// this one iterates rows; does cast(IResultRow)this
>#	int IResult.opApply( int delegate(inout IResultRow) dg );
>#	// this one iterates fields; does new ResultField(this,fieldno)
>#	int IResultRow.opApply( int delegate(inout IResultField) dg );
>#}

I do not see the problem here because the opApply from the different interfaces
do not have identical formal parameter lists. Therefore your code above is very
vlose to the solution:

#class Command : IResult, IResultRow {	// handle wrapper
#	sqlite3_stmt* stmt;
#	~this() { sqlite3_finalize(stmt); }
#	IResult Execute() { return this; }
#	// this one iterates rows; does cast(IResultRow)this
#	int opApply( int delegate(inout IResultRow) dg );
#	// this one iterates fields; does new ResultField(this,fieldno)
#	int opApply( int delegate(inout IResultField) dg );
#}





More information about the Digitalmars-d-learn mailing list