D - function pointers not working
- curtis (23/23) Nov 24 2003 Whenever I try to use function pointers (both the c and d way) or delega...
- Charles Sanders (7/30) Nov 24 2003 fp = &foo;
Whenever I try to use function pointers (both the c and d way) or delegates I get an error like the following: C:\projects\dsamples>dmd functionpointers.d functionpointers.d(9): cannot implicitly convert int to int(*)() which is what I get when I compile the following code (which is taken directly from the manual): int function() fp; void test() { static int a = 7; static int foo() { return a + 3; } fp = foo; } void bar() { test(); int i = fp(); // i is set to 10 } int main(char[][] args) { test(); return 0; } thx curtis
Nov 24 2003
fp = &foo; Docs need updating. C "curtis" <curtis_member pathlink.com> wrote in message news:bpubm0$58g$1 digitaldaemon.com...Whenever I try to use function pointers (both the c and d way) ordelegates Iget an error like the following: C:\projects\dsamples>dmd functionpointers.d functionpointers.d(9): cannot implicitly convert int to int(*)() which is what I get when I compile the following code (which is takendirectlyfrom the manual): int function() fp; void test() { static int a = 7; static int foo() { return a + 3; } fp = foo; } void bar() { test(); int i = fp(); // i is set to 10 } int main(char[][] args) { test(); return 0; } thx curtis
Nov 24 2003