Please, advice on usturct

Hey, everyone! Still trying to get grisp of c++…

Before this, I was always using TArray<SomeUCLass*> to handle stuff, it just works;

Then, I decided to also connect DataTables in my game, so had to use ustructs, and ending up with something like


So, before this, I could access data like this:


and now


My question is:

do I need any extra manual handling now? Like, I am actually accessing data copy here or direct data? I guess I can not treat struct same as pointer, need something else to keep in mind?

Also, am I correct, that when passing it to the function, I should always use:


i.e., pass it as reference?

Before this, I did:


I just want to avoid common mistakes, like creating memory leaks or data copies.

Is there abything else I should know or might be forgetting?

I know that I can read any online manual data on pointers and structs in depth, but I guess UE4 adds its own flavor to all this, so I need to ask here to be sure. Thanks!

Nothing you’ve asked is UE4 specific.

Anyway, no you are not copying anything by accessing with the ‘.’ operator; just be aware that anytime you add to the array, or copy something from it, you will be copying the struct as a whole, whereas before all you copied was a pointer. Depending on the contents of the struct, this may or may not be significant.

And yes, generally pass it by reference, const reference where possible.