Unreal 4.24.3 : How to Declare UPROPERTY() inside .cpp file

What I want to do:

Create a USceneComponent at Runtime in an Actor class

	USceneComponent* UnitDesign = NewObject<USceneComponent>(this, FName(*ID));

What works:

Defining UnitDesign at Header File(.h) works without issues…

UPROPERTY(VisibleAnywhere)	//I can see UnitDesign in World Outliner
USceneComponent* UnitDesign = NewObject<USceneComponent>(this, FName(*ID));

What does not work for me:

Defining UnitDesign at CPP File(.cpp) inside BeginPlay() of Actor class-

UPROPERTY(VisibleAnywhere)	//I can NOT see UnitDesign in World Outliner
USceneComponent* UnitDesign = NewObject<USceneComponent>(this, FName(*ID));

Any pointers appreciated.

How to Declare UPROPERTY() inside .cpp file

You don’t.

You have to declare the UPROPERTY in the header but can assing the object in the source file

.h

UPROPERTY()
USceneComponent* MyComponent;

.cpp

MyComponent = NewObject<USceneComponent>(...);