I need help with casting using C++

Hello i’ve been trying to cast a specific game mode class to my player character so i can access a variable stored in that game mode, the idea behind it is that within this game mode will be stored variables that will determine what units for measurements will be displayed

so far in regards to casting i have tryed the following
attempt 1

player.h
public:
AGameModeBase* UUE;

player.ccp
public:
ADefaultGameMode* Stock = Cast(UUE);
if(Stock != NULL){
Description += " 1 ";
*Stock->Units;
}
else{
Description += " 0 ";
}
result
all ways results in 0

attempt 2

player.h
public:
ADefaultGameMode* UUE;

player.ccp
public:
ADefaultGameMode* Stock = Cast(UUE);
if(Stock != NULL){
Description += " 1 ";
*Stock->Units;
}
else{
Description += " 0 ";
}

result
all ways results in 0

any help with casting with C++ would be appricated, also is there a cast to class in C++ and if so how do i do it, i would also would like any alterative suggestions

ps i have also tried using both static_cast and dynammic_cast

thank you for your time

Try:

YOURGAMEMODECLASS* gamemode = Cast<YOURGAMEMODECLASS>(GetWorld()->GetAuthGameMode());
if (gamemode)
{
	...
}

or:

#include "Kismet/GameplayStatics.h"
     
YOURGAMEMODECLASS* gamemode = Cast<YOURGAMEMODECLASS>(UGameplayStatics::GetGameMode(GetWorld()));
 if (gamemode)
 {
     ...
 }