Function default parameters
Tim M
a at b.com
Thu Nov 13 17:34:25 PST 2008
I want to use the return value of another member function as the default
for a parameter. I could just overload it but I would prefer to do it like:
module test;
class Thing
{
char[] getString(uint len = this.strLen())
{
char[] a = new char[len];
return a;
}
uint strLen()
{
return 6;
}
}
int main()
{
Thing t = new Thing;
char[] abc = t.getString;
return 0;
}
test.d(6): Error: 'this' is only defined in non-static member functions,
not Thing
More information about the Digitalmars-d-learn
mailing list