Pointers and references? I need some help

Hello. I’m reading a tutorial here: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums

I don’t seem to understand. Here’s one part of code:

// Variable to hold the widget After Creating it.
UUserWidget* MyMainMenu;

and here’s another part:

// Create the widget and store it.
		MyMainMenu = CreateWidget<UUserWidget>(this, wMainMenu);

But how? Aren’t pointers only able to hold the address of a variable? I’m assuming CreateWidget is a templated class, would that be correct? How is a pointer able to point directly to it?

As for your question about the pointer: No, pointers can clearly also point to objects! In this case of type UUserWidget.

This is basic c/c++ stuff. An integer, a floating point, a string, an object, a widget, or anything really, is just a series of bytes in memory, pointer holds the address to that series of bytes along with the information about what kind of thing it points to.

CreateWidget is not a templated class, it is a templated function that returns a pointer to a widget.

Ah okay, thanks. That’d make sense.

I think it’s just pointing to the memory of the object because in this case the function returned it.