Which GetWorld?

What is the difference between AActor::GetWorld and
UWorld::GetWorld, as both of them can include GetWorld()
but they have different header files. So which one are we using here and why?

Whichever class you’re calling GetWorld on.

class USomeWorld : public UWorld
{
    void Foo()
    {
        GetWorld(); //UWorld::GetWorld
    }
};

class ASomeActor : public AActor
{
    void Foo()
    {
        GetWorld(); //AActor::GetWorld
    }
};

Privacy & Terms