How to create pointer of UCLASS object with new operator?

When i try to create new pointer to class using operator new, i get error E0384, that says that operator new doesn’t match overloaded arguments (unsigned long long). How can i do it, then?

UItemStack *ret = new UItemStack(m_stack->GetItem(), count); //E0384

For UObject, you shouldn’t use the new operator. Take a look at this article:

For UObjects, you use “NewObject” or “StaticConstructObject” function. Find more information here:

Then if you need a pointer to the UClass of the object, you call the object’s GetClass() func or call UItemStack::StaticClass().

1 Like

Can you give an example ?