Error when creating a UInstancedStaticMeshComponent in C++

I’m trying to create an instance of UInstancedStaticMeshComponent as seen in many topics online. But the same code that works for others is not working for me.This is what I have so far, a super simple class:


class FPSTEST2_API MyActor : public AActor

    UPROPERTY(VisibleDefaultsOnly, Category=Mesh)
    class UInstancedStaticMeshComponent* InstancedMesh;
	// Sets default values for this actor's properties

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

MyActor.cpp (constructor only):

	PrimaryActorTick.bCanEverTick = true;

        InstancedMesh = CreateDefaultSubobject<UInstancedStaticMeshComponent>(TEXT("Test")); // The problem is here

The compiler throws me this error: “use of undefined type ‘UInstancedStaticMeshComponent’” in the definition of CreateDefaultSubobject:

template<class TReturnType>
TReturnType* CreateDefaultSubobject(FName SubobjectName, bool bTransient = false)
	UClass* ReturnType = TReturnType::StaticClass(); // This is where the error pops up
	return static_cast<TReturnType*>(CreateDefaultSubobject(SubobjectName, ReturnType, ReturnType, /*bIsRequired =*/ true, /*bIsAbstract =*/ false, bTransient));

I can’t find the solution anywhere. I’ve seen this code in plenty of pages and it should work…

Nevermind, I seem to have fixxed. Had to add this include:
#include “Components/InstancedStaticMeshComponent.h”

It’s weird because in other code snippets I’ve seen they don’t do that. Might be that they’re outdated and now you have to manually add it, I don’t know… Also in the header I didn’t have to add it.