Creating a function to get the distance between two actors

Hi, I’m new in C++, I’m trying to code a function to get the distance between to actors like this:

float UMyBPFunctionLibrary::Distance(AActor* Actor_A, AActor* Actor_B)
FVector Actor_ALocation = Actor_A->GetActorLocation();
FVector Actor_BLocation = Actor_B->GetActorLocation();

return sqrt((Actor_BLocation.X - Actor_ALocation.X) ^ 2 + (Actor_BLocation.Y - Actor_ALocation.Y) ^ 2 + (Actor_BLocation.Z - Actor_ALocation.Z) ^ 2);


What’s wrong with it?

That its the long way of doing it in UE4?

FVector already has operators / functions for a bunch of things, including length/size.

float UMyBPFunctionLibrary:istance(AActor* Actor_A, AActor* Actor_B)
    return (Actor_A->GetActorLocation() - Actor_B->GetActorLocation()).Size();