On Fri, 03 Jul 2009 17:42:45 -0400, Mike L. <sgtmuff...@myrealbox.com>
wrote:
module test;
import std.stdio;
abstract class Parent
{
int opApply(int delegate(ref int) dg)
{
int fakeDelegate(ref uint fake, ref int content)
{ return dg(content); }
return opApply(&fakeDelegate);
}
abstract int opApply(int delegate(ref uint, ref int) dg);
}
class Child : Parent
{
/* add this line (see
http://www.digitalmars.com/d/2.0/function.html#function-inheritance) */
alias Parent.opApply opApply;
override int opApply(int delegate(ref uint, ref int) dg)
{
uint index = 0;
for(int content = 1; content < 6; content++)
{
int result = dg(index, content);
if(result != 0)
return result;
index++;
}
return 0;
}
}
void main()
{
version(works)
Parent child = new Child();
else
Child child = new Child();
foreach(int content; child)
writefln(content);
}