c++ - Why expressions a() and (****&a)() call the same function? -


there code:

void a() { }  int main(){    a();    (****&a)();    return 0; } 

how happen statement (****&a)(); has same effect a();?

it's because of function-to-pointer conversion (§4.3):

an lvalue of function type t can converted prvalue of type “pointer t.” result pointer function.

&a first gives pointer a. dereference * giving function itself. attempt dereference function, since can't, undergoes function-to-pointer conversion pointer again. dereference pointer *, , on.

in end (****&a) denotes function a , call it, since can apply () function without undergoing function-to-pointer conversion.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -