Games crashes when calling a function from another actor class

So that line: ABackAndForthActor * BackAndForthActor; just declares a pointer to an instance of ABackAndForthActor, you need to spawn on somewhere and get a reference to it.

You can either do this in this class somewhere using GetWorld()->SpawnActor

Or you could spawn it somewhere else / put one in the level in the editor and get a reference to it, eg with something like UGameplayStatics::GetActorOfClass