Delegate of a Function that Returns an Int
Part of DelegateCategory
Description
More complicated than DelegateNonStaticNestedFunctionExample.
Example
struct Foo { int a = 7; int bar() { return a; } } int foo(int delegate() dg) { return dg() + 1; } void main() { int x = 27; int abc() { return x; } Foo f; int i; i = foo(&abc); /* i is set to 28 */ i = foo(&f.bar); /* i is set to 8 */ }
Source
From http://www.digitalmars.com/d/function.html#closures
| Link | http://www.dsource.org/tutorials/index.php?show_example=61 |
| Posted by | jcc7 |
| Date/Time | Wed Aug 11, 2004 6:56 pm |
