In this line of code
PlayerInputComponent->BindAxis("MoveForward", this, &APawnTank::CalculateMoveInput);
Why are we passing a reference and why do we need to specify a namespace? Otherwise it wont compile, but why? Why cant we just pass an adress?
—Edit—: i realised my mistake about 1 thing: & - isn’t a reference, we are asking for adress, but an adress of what? As far as i remember if we write a function name without brackets then we get the function’s adress (correct me if i am wrong), but what will we get by writing &FunctionName i am not sure, so the question still stands.
—Edit2—:
So i decided to play with the code to see if i can recreate something similar and i did this
#include <iostream>
using namespace std;
class CLS1
{
public:
void func1()
{
cout << "Hello" << endl;
}
void func2()
{
//cout << func1 << endl; wont compile
//cout << &func1 << endl; wont compile
//cout << CLS1::func1 << endl; wont compile
cout << &CLS1::func1 << endl;
}
};
int main()
{
CLS1 a;
a.func2();
}
What i got from this is that you cant just get an adress of a method (function that is located inside a class) inside another method of the same class. I am guessing that this is because this adress doesnt exist until you create an instance of a class, but i may be wrong. But still i am not sure how & and :: are fixing this issue.
Also the outout of this code is: 1
Why?