CATEGORII DOCUMENTE |
Asp | Autocad | C | Dot net | Excel | Fox pro | Html | Java |
Linux | Mathcad | Photoshop | Php | Sql | Visual studio | Windows | Xml |
A useful technique is the ability to have pointers to functions. Their declaration is easy: write the declaration as it would be for the function, say
int func(int a, float b);and simply put brackets around the name and a
in front of it: that declares the
pointer. Because of precedence, if you don't parenthesize the name, you declare
a function returning a pointer:
Once you've got the pointer, you can assign the address of the right sort of function just by using its name: like an array, a function name is turned into an address when it's used in an expression. You can call the function using one of two forms:
The second form has been newly blessed by the Standard. Here's a simple example.
#include <stdio.h>Example 5.16
If you like writing finite state machines, you might like to know that you can have an array of pointers to functions, with declaration and use like this:
void (*fparr[])(int, float) = ;Example 5.17
But we'll draw a veil over it at this point!
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 709
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved