Why is there no paranthesis at the end of &UGrabber::Grab?

Hi,
In BindInput() we passed the adress of a function as a parameter (hopefully this is the right way to word it) like so;

InputComponent->BindAction("Grab", IE_Pressed, this, &UGrabber::Grab);

My question is: why don’t we need to include () at the end of the function name like we normally would? for example:
UGrabber::Grab()
Won’t this cause issues if Grab() had overloads?

The parentesis are required when you call the function. In this case we only refer to the function, telling the compiler where to find it. It’s not that line that does the call but the bound action inside the InputComponent.

2 Likes

Yes, but the ambiguity can be resolved by explicitly specifying the template parameters of the BindAction<>() function. However, you should try not to worry about that right now, because that function is a variadic template, a quite advanced topic from the newest versions of C++.

Privacy & Terms