What does "*" mean in C++(noob question)

It means that the variable called ‘MyActor’ points to a place in memory, where an object of type AActor is stored. This is called a pointer and is very important in C/C++ programming.

Imagine a function that needs your ‘GameWorld’ (or any other large object/struct):

exampleFunction(World GameWorld) {...};

In the case shown, you would pass a copy (!) of the current GameWorlds status (current Data) to the function call, which can take a lot of time and memory, depending on the object size. You cannot alter the original GameWorld this way, all changes would be applied to the copy of it.

exampleFunctionPointer(World* GameWorld) {...};

Now the function does not get a copy of the GameWorld. It will just be given the location inside the memory, where the existing GameWorld ist stored. The function can access this storage location and pull out the data it needs (specified in the function body), and ONLY the data it needs, not more. Furthermore the function can ALTER the GameWorld directly, because its original is accessed.

There’s plenty of tutorials and explanations for pointers out there, take your time learning pointers since they can easily crash your programs (nullptr exceptions, if you access the address 0x000…00).

I’m a complete noob when it comes to c++ and can’t find anything that will give me an answer to my question.
What does the “*” do/mean in
AActor* MyActor?
Thanks for taking the time to answer this noob question.

Extra info, pointer is latterly memory address pointing to variable (not only object, but only UObjects is commonly used with pointers in UE4), it operates same way as integer with address in it and you use * (on varable name not type) and -> operators to access things that is pointing to, Thats why you use -> on UObjects insted of “.”. If wither you got nullptr or invalid address in pointer and you try to access it you either gonna get trash data (Especially in invalid pointer) or crash

Any data of any type created dynamically on runtime in C++ is returned as pointer, as well as oyu can turn anything to pointer with & operator (but i don’t recommend that with UE4 or else it’s really needed). Also UObject can be only be referenced by pointers, because UE4 heavily manage them for variues engine function as well as control there lifecycle, so you can only reference them in pointers, if you try exampleFunction(UWorld GameWorld) {...}; you most likely gonna have a crash.

This is little outside of topic but, you might find advance custom made pointers like TSharedPtr that use both . and → where with . you control pointer it self and with → you access pointer, some types like FString use * operator to access raw data of type on this case TCHAR array. In general * (again not on type but variable name) and → means accessing things that other point referencing to and you can overload behavior of those operators…