A detailed C + + function pointer Declaration (* (Void (*) ()) 0) ();

Source: Internet
Author: User

(  * (void (*) ()) 0) ();

Float*PF; The implication of this statement is that*PF is a floating-point number, which means that PF is a pointer to a floating-point number. float*g (), (*h) (); Express*g () and (*h) () are floating-point expressions. Because () The binding priority is higher than *,*g () is the *(g ()): G is a function in which the return value type is a pointer to a floating-point number. Similarly, you can conclude that H is a function pointer, and that the return value of the function that H points to is a floating-point type. float(*h) (); Indicates that H is a pointer to a function that returns a value of floating-point type, so (float(*) ()) represents a type conversion character that refers to a pointer to a function that returns a floating-point type . The first step is to assume that the variable FP is a function pointer , so how do you invoke the function that the FP points to? The method is called as follows: ( *FP) (); Because FP is a function pointer,*FP is the function that the pointer points toSo(* FP) () is the way the function is called . An expression (*FP) (), the parentheses on both sides of the *fp are important because the function operator () takes precedence over the single-mesh operator *. If there are no brackets on both sides of the *FP, then *FP () actually(FP ()) means exactly the same. (*0) () is not valid because the operator* You must have a pointer to do the operand. And this pointer should also be a function pointer, so that the operator *The result of the action can be called as a function. Therefore, a 0 type conversion must be made in the above, and the converted type can be roughly described as "a pointer to a function that returns a value of type void." Therefore, the conversion of constant 0 to "pointer to a function with a return value of void" can be written like this: (void(*) ())0of course, we use typedef to solve this problem can be expressed more clearly:12typedefvoid(*FP) ();//declaring a function pointer type FP(* (FP)0)();//the conversion of 0 to a function pointer type, * (function pointer) is the function itself,

A detailed C + + function pointer Declaration (* (Void (*) ()) 0) ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.