How to spawn a cube in C++?

I need to spawn a few cubes to specific coordinates when I start the game. I want to do it with C++ but I can’t figure out how. All I found about this was outdated info or people using blueprints.

I hope someone can help me.

Hi,
this answer should work: https://answers.unrealengine.com/questions/579025/how-to-create-a-cube-manually-from-c-code.html

But this is not for spawning actors

Ok, not sure to understand, here is my code to create a mesh: my class inherite from AActor. Maybe you can find a method that create automatically a cube geometry, otherwise here is how I draw myself the geometry:

ASofaVisualMesh::ASofaVisualMesh()
{
        mesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("GeneratedMesh"));
	RootComponent = mesh;
}

void ASofaVisualMesh::BeginPlay()
{
	Super::BeginPlay();

    TArray<FVector> vertices;
	TArray<int32> Triangles;
	TArray<FVector> normals;
	TArray<FVector2D> UV0;
	TArray<FProcMeshTangent> tangents;
	TArray<FLinearColor> vertexColors;

    // For a cube it should be something like:
    for(int i=0; i<8; ++i)
    {
            vertices.Add(FVector(..., ..., ...));
            normals.Add(....
    }

    for (int i = 0; i < 12; i++)
	{
               //create here the faces of the cube
	}
	
	mesh->CreateMeshSection_LinearColor(0, vertices, Triangles, normals, UV0, vertexColors, tangents, true);

	// Enable collision data
	mesh->ContainsPhysicsTriMeshData(true);
}

If you go into detail about what you are trying achieve and what is blocking you we’ll be able to help you more.