-
-
Notifications
You must be signed in to change notification settings - Fork 9
Function Address
IsaacShelton edited this page Mar 21, 2022
·
1 revision
The func &
operator is used for obtaining the memory address of a function.
If arguments are not specified, then the first function defined with the given name will be matched. A warning will be issued if other functions with the same name exist.
func &sum
If arguments are specified, then the specific function with "matching" argument types will be given.
func &sum(int, int)
import basics
func main {
my_function_pointer func(int, int) int = func &sum
printf("8 + 13 = %d\n", my_function_pointer(8, 13))
}
func sum(a, b int) int {
return a + b
}