Different forms of function modifying functions

xiaoxiao2021-03-17  187

Different forms of MA JIA NAN 2006-1-16 with pointer modified functions

The initial function pointer must be "converted to" a "real" function to call with * operator (and a parentheses), as follows: int R, func (), (* pf) () = func; // The initialization R = (* pf) (); // function pointer call form 1, equivalent to r = func (); function always calls through the pointer, all "real" function names are always hidden The degradation of the formula is a pointer to this function, just as in initialization of the function pointer PF: int func (); int (* pf) () = func; this is a bit similar to the number of group names (without subscript operator The number of group names will be interpreted to point to the pointer to the array header). The above conclusions show that the following statements are also correct. R = PF (); // Function pointer Call Form 2 ANSI C standard actually accepts form 2, which means no longer need * operator, but form 1 is still allowed. Both forms produce the same result, but the form 1 lets the reader more clearly that the call is performed by the function pointer.

转载请注明原文地址:https://www.9cbs.com/read-129582.html

New Post(0)