Technically references are pointers but you work with them using nonpointer syntax. It’s just syntactic sugar introduced in C++ over pointers in C. It’s also easier to work with references than pointers when they are function params since you can do stuff like this:
void doStuff(const FVector& someVector)
FVector someVector(0.f);
doStuff(someVector);
doStuff(FVector(1.0, 2.0, 3.0));
Whereas if you use pointers it becomes a headache.
void doStuff(const FVector * someVector)
doStuff(&someVector);
FVector someVector2(1.0, 2.0, 3.0); // can't write the vector param inline
doStuff(&someVector2);
It’s also possible at runtime or with weird typcasting at compile time to assign null to a reference. If you avoid dirty hax while coding you’ll very rarely accidentally assign null to a reference.
If something isn’t a pointer or a reference it’s allocated statically on the stack versus dynamically on the heap. In languages like Java or C# you can’t ever do that with an object. C# does let you do stuff with structs last I checked. In pure non UE4 C++ there is no difference between a struct and a class, except struct params are public by default. This is different if working with UE4 C++ when you work with things that extend UObject since UObjects are classes managed by the garbage collection system of C++ and structs are just structs. But you can mix and match pure C++ with UE4 C++ seamlessly, it just won’t integrate with blueprint whatsoever.
void someFunc() {
FVector staticallyAllocatedVector(1.f, 2.f, 3.f);
SomeCppClass staticallyAllocatedCppClass(someConstructorParam);
SomeCppClass * dynamicallyAllocatedCppClass = new SomeCppClass(someConstructorParam);
AActor * SomeUnrealActor = SpawnActor<AActor>(whatever the spawn actor function call was and its params go here);
someOtherFunc(staticallyAllocatedVector, &staticallyAllocatedVector, staticallyAllocatedCppClass, dynamicallyAllocatedCppClass, *dynamicallyAllocatedCppClass, SomeUnrealActor);
}
void someOtherFunc(FVector& vectorReference, FVector * vectorPointer, SomeCppClass& classRef, SomeCppClass * classPtr, SomeCppClass classCopy, AActor * someActorPtr)
{
vectorReference.X = 10.f; //this modifies X in staticallyAllocatedVector that was passed in from someFunc()
vectorPointer->Y = 5.f; //this modifies Y in staticallyAllocatedVector that was passed in from someFunc()
classRef.x = 10.f; //this modifies x in staticallyAllocatedCppClass that was passed in from someFunc()
classPtr->x = 20.f; //this modifies x in dynamicallyAllocatedCppClassthat was passed in from someFunc()
classCopy.x = 1.f; //classCopy is copied completely when passed from someFunc() and this modifies the local param copy as opposed to the original object, avoid making params that are entire classes or structs to avoid full copies, pass them by const reference instead so it points to the original object e.g. const SomeCppClass& constClassRef so it's immutable
someActorPtr->SetActorTransform(FTransform(FRotator(1.f, 2.f, 10.f), FVector(1.f)); //sets transform on SomeUnrealActor passed in from someFunc
}