Thread overview |
---|
June 30, 2012 function pointer when a function is overloaded. | ||||
---|---|---|---|---|
| ||||
Simple question. How to I get a function pointer to one of the foo functions in this case : void foo(int i); void foo(long i); |
June 30, 2012 Re: function pointer when a function is overloaded. | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | import std.stdio; alias void function(int) fooInt; alias void function(long) fooLong; int main(string[] args) { fooInt f1 = &foo; fooLong f2 = &foo; f1(1L); f2(1L); return 0; } void foo(int i) { writeln("foo(int i)"); } void foo(long i) { writeln("foo(long i)"); } |
July 01, 2012 Re: function pointer when a function is overloaded. | ||||
---|---|---|---|---|
| ||||
Posted in reply to dnewbie | Le 01/07/2012 01:59, dnewbie a écrit :
> import std.stdio;
>
> alias void function(int) fooInt;
> alias void function(long) fooLong;
>
> int main(string[] args)
> {
> fooInt f1 = &foo;
> fooLong f2 = &foo;
> f1(1L);
> f2(1L);
> return 0;
> }
>
> void foo(int i)
> {
> writeln("foo(int i)");
> }
>
> void foo(long i)
> {
> writeln("foo(long i)");
> }
Thanks.
|
Copyright © 1999-2021 by the D Language Foundation