Why can I not see any static mesh?

I have in my header file:

UPROPERTY(EditAnywhere, Category = "Static Mesh") UStaticMesh *mesh; UStaticMeshComponent *meshComponent;

and in my constructor I have:

meshComponent = CreateDefaultSubobject("Mesh"); if (mesh) meshComponent->SetStaticMesh(mesh);

In the details panel in the editor I have the static mesh set to the cube, nothing shows up, why is this and what am I doing wrong?

Hi,

Please try this. Hope it helps.

/** HEADER */
private:
/** set the static mesh of actor */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Static Mesh", meta = (AllowPrivateAccess = "true"))
class UStaticMeshComponent* MeshComponent;

// CPP FILE
// need to include in cpp file
#include "Components/StaticMeshComponent.h"

MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
RootComponent->SetupAttachment(MeshComponent());