C++ pointer to incomplete class type is not allowed

Hi,

I am following a tutorial on how to get the name of an object with c++. This is my code:

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

#include "PositionReport.h"


// Sets default values for this component's properties
UPositionReport::UPositionReport()
{
	// 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.
	PrimaryComponentTick.bCanEverTick = true;
	
	// ...
}


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

	// ...
	FString ObjectName = GetOwner()->GetName;
	UE_LOG(LogTemp, Warning, TEXT("Position report for %s"),*ObjectName);
}


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

	// ...
}

but when I try to compile it I get the error “C++ pointer to incomplete class type is not allowed” for this line of code

FString ObjectName = GetOwner()->GetName;

How do I fix this?

Hey, make sure to include the actor.h file since Unreal changed to a IWYU model.

#include "GameFramework/Actor.h"

Hey, could you fix your code with my solution? If there is no more questions, can you make sure to hit the resolved button? <3