Example for a HUD class adding a SceneComponent:
USceneComponent* WidgetComponentRoot = Cast<USceneComponent>(AddComponentByClass(USceneComponent::StaticClass(), true, FTransform::Identity, false));
WidgetComponentRoot->AttachToComponent(GetDefaultAttachComponent(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, true), NAME_None);
Example how to add an ActorComponent from an ActorComponent to its owning AActor:
UChildActorComponent* CAGrabSlot = Cast<UChildActorComponent>(Owner->AddComponentByClass(UChildActorComponent::StaticClass(), false, FTransform::Identity, false));