Attaching a StaticMeshComponent to A SceneComponent

I am trying to to achieve the following hierarchy:

Pawn → StaticMeshComponent (Root Component) → SceneComponent A → StaticMeshComponent B

In other words: My pawn has a mesh-representation, and my scene component A also has one with B. I use the following code to achieve this in the SceneComponent A:

{
	GENERATED_BODY()

public:	
	UPROPERTY(EditAnywhere)
		bool bActivated = false;
	UPROPERTY(EditAnywhere)
		UStaticMeshComponent* mesh;
	// Sets default values for this component's properties
	UModule();

	// Called when the game starts
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;

		
	
};

Where UstaticMeshComponent* mesh ist the pointer for B. I initialize it in the constructor:

UModule::UModule()
{
	// 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.
	bWantsBeginPlay = true;
	PrimaryComponentTick.bCanEverTick = true;
	mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("mesh"));
	
	// ...
}

This is the result:

Both A and B are children of the RootComponent, not B child of A. I can edit the mesh of B through A (were B is accessible and editable), but not its material. When I select it I cant change its properties, because the engine says it is inhereted and must be declarde with Uproperty (which I did). It does not render in editor, but when I hit play it does. When I hover over it, it says “Introduced in: Unknown native source (via C++ code)” which makes absolutely no sense to me.

So I would like to know how to fix this and if my approach to giving both A and the pawn a mesh is right (I didnt find a way to include the mesh in the A itsself)

I have tried this in 4.10.4 and 4.12.3

Thank you for your help!

mesh->SetupAttachment(Module);
is what you are looking for.

I should have closed this question a while ago since I found the answer, but yours is of course correct!
One thing to add: SetupAttachment(Module) only works for components that have not yet been registered by RegisterComponent(). If it has been registered, one has to use AttachToComponent(Module)