Has the ban on returning function nested structs been lifted?
Andrej Mitrovic
andrej.mitrovich at gmail.com
Fri Mar 18 10:10:49 PDT 2011
This seems to work with classes as well. The TDPL has an example of a
class that subclasses a class definition in module scope. But this one
is defined in function scope, doesn't derive, and still works:
void main()
{
auto local = foo(0);
assert(local.sum() == 30);
}
auto foo(int a)
{
int z = a + 10;
class Local
{
int x = 10;
int y = 10;
int sum()
{
return x + y + z;
}
}
return new Local();
}
More information about the Digitalmars-d
mailing list