Duplicate UObject into another one

My code:

.h

UPROPERTY(EditAnywhere)

AActor *BulletTemplate = nullptr;

.cpp

std::wstring name = std::wstring(L"Bullet_") + std::to_wstring(itemNum++);

UObject *outer = BulletTemplate->GetOuter();

AStaticMeshActor *bullet = DuplicateObject(Cast(BulletTemplate), outer, name.c_str());