Higher-order functions: Difference between revisions

→‎Simple example: Removed syntax highlighting
(→‎[[C]]: Added syntax highlighting)
(→‎Simple example: Removed syntax highlighting)
Line 16:
 
Definition of a function whose only parameter is a pointer to a function with no parameters and no return value:
 
<highlightSyntax language=C>
void myFuncSimple( void (*funcParameter)(void) )
{
Line 26:
/* ... */
}
</highlightSyntax>
 
Note that you ''can't'' call the passed function by " *funcParameter() ", since that would mean "call funcParameter and than apply the * operator on the returned value".
Line 32 ⟶ 31:
Call:
 
<highlightSyntax language=C>
void funcToBePassed(void);
Line 38 ⟶ 36:
myFuncSimple(&funcToBePassed);
</highlightSyntax>
 
===Complex example===