So, I’ve been doing C++ for like 3 months now, and I wanted to dig deeper into pointers to finally understand them completely.
I’m familiar with what they are, and how they work, I just have this one question:
The last 2 lines, the FStrings, one is de-referencing the pointer. But I don’t understand why the 2nd one works and what it’s actually doing.
I really want to get this right. Could anyone please explain it to me?
Even if you are dereferencing your string is still making a copy in your scope, in the case you have you should have something like FString& StringA if you really want to capture the memory data, but in your case is anyway impossible since the info is transforming the vector to a string, this has to be allocated somewhere, the real example for this should be in two ways
FString* StringA = &SomeRealData;
FString& StringA = SomeRealData;
just to anwser your question the last 2 lines are doing exactly the same.
I see. It makes sense.
I know pointers are used to point to actual data instead of making copies of it.
But when would you use a Reference& , like, when is it necessary to declare something as a Reference to begin with?
Edit: You would use References as Function Parameters! I knew that, lol.