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 -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -