Answer the question
In order to leave comments, you need to log in
Explain why this parameter is a pointer in a class method?
William Sheriff's book has this example from a picture. I can’t understand why pass a pointer to a function parameter if it’s not used anywhere else in the body? I'm talking about UPrimitiveComponent* ClickedComp
void APuzzleBlock::BlockClicked(UPrimitiveComponent* ClickedComp)
{
if (!bIsActive)
{
BlockMesh->SetMaterial(0, OrangeMaterial);
if (OnwingGrid != NULL)
{
OwnGrid->AddScore()
}
}
}
Answer the question
In order to leave comments, you need to log in
Judging by the name, this is a callback function that is called by the engine when a block is clicked. In this case, the parameter is a required argument to pass the component that fired the event from the engine to the function. The engine expects the callback function to accept this parameter, whether it is used in the function body or not.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question