TArray of c++ class instance

Let’s assume that there is pure c++ class
‘class AAA {}’.
I want to store instances of ‘AAA’ using TArray, like TArray &ltAAA&gt var. but I found that many example uses TArray&ltAAA*&gt var, instead of TArray&ltAAA&gt var.

What are differences of them? Will I have problem if I use TArray&ltAAA&gt?

On this question, and not getting into the minutiae of number of CPU calls and the incremental memory used by pointers on the stack etc. I think my decision would be dominated by what I intended to do with the TArray. If AAA was not trivial to copy and I planned to do a bunch of things that would trigger non-trivial copying of class instances, I would lean to pointers to leave the class instances undisturbed in memory and just move the pointers around.

Hi, Thank you for your comment.
So you mean, If AAA will be copied frequently, you will use AAA* and if it is not, you will use AAA right?
I just wanted double-check.

That is correct.

Just explain it what it is there really nothing complex to it :stuck_out_tongue: that all he needed as you can see

Theres no problem to use any variable type with TArray as it was made to store any data, in fact it is recommended if oyu use UE4. Issue may rise if you gonna use UPROPERTY() as it only supports types that reflection system supports.

Varbales with * are Pointers, they are Related memory addesses stored in integer variables (32bit for 32bit application 64-bit for 64bit application) they pointing in to some variable in memory which you can read and interact with, while normally setting normal variables copies the value, now instead you only copy memory address.

Is impotent that varables without UPROPERTY are not garbage collected, if you create normal object with new you need to delete later on or else you gonna have memory leak.