Unreal Engine 4.22.2 crashes after adding C++ code

Hello Everyone,

I have recently started using UE4 and I have an issue. I am attempting to get an object name from an object in my level. I have created a class that reports the name of the object in the LOG. I then add the class as a component of one of the chairs in the basic project template. The code is as follows

// Fill out your copyright notice in the Description page of Project Settings.

#include “PositionReporter.h”
#include “GameFramework/Actor.h”

// Sets default values for this component’s properties
UPositionReporter::UPositionReporter()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don’t need them.

}

// Called when the game starts
void UPositionReporter::BeginPlay()
{
Super::BeginPlay();

// If I comment out the line below my code runs fine
FString ObjectName = GetOwner()->GetName();
UE_LOG(LogTemp, Warning, TEXT("Position Reporter Active"));

}

// Called every frame
void UPositionReporter::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

// ...

}

This is the information from the Crash Reporter
Unhandled exception

UE4Editor_Engine
UE4Editor_Escape_Demo_2980!UPositionReporter::UPositionReporter() [C:\Users\developer\Documents\Unreal Projects\Escape_Demo\Source\Escape_Demo\PositionReporter.cpp:13]
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_Core
UE4Editor_Core
UE4Editor_Projects
UE4Editor_Projects
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll

You GetOwner() Function’s return value may be NULL.