c++ - Why expressions a() and (****&a)() call the same function? -
this question has answer here:
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
tcan converted prvalue of type “pointert.” 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
Post a Comment