Manipulating mesh with c++ code

How do I set the mesh and then manipulate it from within the code? In example I’d like an object that has 2 parameters uint32 width and uint32 height and then use them to create a cube of such size and I want to do it all using only the code. So I create UStaticMeshComponent* with FObjectInitializer, but what do I do then? How do I set it to be a cube and how I manipulate its parameters?