I am new to Unreal Engine 4 and CPP, I was actually quite understand how programming concept works, but I do not really understand how does CPP in UE4 works as it seems quite different with native CPP (CMIIW).
So, I’ve been trying to learn CPP in UE4, I found a video and followed the tutorial, it worked well.
I know that * and & should be talking about pointer. APawn is the Pawn Class. Does this mean MyPawn is a parameter that will be assigned with the memory value of APawn in the game?
APawn* MyPawn does not get a new memory address, because when the function is called, a Pawn already exists, because you need something to be that parameter. The thing about pointers is that one object exists in the memory, and the pointers just show where it is, point to its location, hence the name – pointer.
This is the line of code that will be using the OnPossess() as you stated before APawn does already exist in the memory, after Super::OnPossess(MyPawn); has been called to run, every time the system try to use MyPawn, MyPawn will be pointing the APawn class? So that it could get the components?
Yes, the instance of the pawn class already exists in the level, and it’s already referenced in memory. All pointers will lead to that one instance of the pawn class.