Could I please get some help understanding code(mainly pointers)?

Hi, I am trying to learn how pointers work in UE4. I generally got idea what pointers are in c++. But I feel confused the way they wok in UE4.

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
	TSubobjectPtr<class USpringArmComponent> CameraBoom;

According to my understanding, this creates an instance of the class SpringArmComponent and creates a pointer CameraBoom pointing to that instance.

And from the .cpp

CameraBoom = PCIP.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom"));

I have seen PCIP code many times but got no idea what it does.


Basically this attaches the SpringArm that was created to the root component of the character.


CameraBoom->TargetArmLength = 300.0f;

Changes the value for our instance using the pointer.

FPostConstructInitializeProperties (PCIP) -
Internal class to finalize UObject
creation (initialize properties) after
the real C++ constructor is called.

  • UObjectGlobals.h (line 639)

TSubobjectPtr - Subobject
pointer. Prevents anything C++ from
overwriting the subobject pointer.
It can only be assigned to with
PCIP.CreateDefaultSubobject (via

  • UObjectGlobals.h (line 575)

If you understand c++ pointers you shouldnt have problems with understanding unreal pointers library but if you still feel unsure check out this site: Pointers - C++ Tutorials . Also, always use “go to definition (F12)” option in VisualStudio to check out some comments about Unreal internal variables.

c++ doesn’t use →
Where is → used generally?

CameraBoom->TargetArmLength = 300.0f;

Wait, just a question, does the pointer here work like structures? “->” Instead of “.”?

Like for example if we created CameraBoom a instanced class pointer. So, is CameraBoom->TargetArmLength similar to that like CameraBoom.TargetArmLength of a structure?

Dude… Data structures - C++ Tutorials and pointers - Arrow operator (->) usage in C - Stack Overflow

Yes this is what I mean but I couldn’t write it in a proper manner.

The thing is I was taught to reference with * in college but not with → so I was confused till now. Thanks a lot :slight_smile:

So if we reference a class with a pointer, we can use → to get all the variables of the class right?

all public members of this class, yes.