How to solve 'This blueprint (self) is not a PrimitiveComponent, therefore ' Target ' must have a connection.' when migrating from Blueprint to C++

The following code works in Blueprint

I’ve attached my skeletal mesh components like this

Now, I’d like to migrate to C++. First, I replace the declaration of the meshes to happen inside my C++ class for the actor:

// Sets default values
ABaseWeapon::ABaseWeapon()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComp"));
	SetRootComponent(SceneComponent);
	RootComponent = SceneComponent;

	MeshFPP = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("MeshFPP"));
	MeshFPP->SetOnlyOwnerSee(true);
	MeshFPP->SetupAttachment(SceneComponent);

	MeshTPP = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("MeshTPP"));
	MeshTPP->SetOwnerNoSee(true);
	MeshTPP->SetupAttachment(SceneComponent);

}

Unfortunately, now I get this:

Since I’ve essentially done the same thing the Blueprint was doing, I’m not sure what’s wrong. I understand it says the types are misaligned, but I believe my variables are of all the same types as they were in the blueprint. I assume self refers to the root scene component, so I do not understand why it now says This blueprint (self) is not a PrimitiveComponent, therefore ' Target ' must have a connection. when self should still be referring to my root scene component.

I think the issue is with the Default Scene Root component. Maybe in a pure blueprint the Default Scene Root is automatically assumed from Self, but in Cpp you substitute it with the custom scene component and Self does not find it anymore?

Try connecting the Scene Component as target and check Propagate to Children (Don’t forget to mark your Scene component as UPROPERTY(BlueprintReadOnly) or UPROPERTY(BlueprintReadWrite) first in your .h file).