Hello, I’ve been following the Unreal Bulls & Cows course for a while & have been successful in following along & retaining knowledge of the course.
However, when I took the “Out Parameters” chapter & attempted to pass the “Bulls” & “Cows” variables into the “GetBullCows” function, it returns an error in Unreal.
I am currently running Unreal Editor 4.22 with Visual Studio 2019. with no internet connection.
Here is my code:
// Show the player Bulls and Cows
int32 Bulls, Cows;
GetBullCows( PlayerInput, Bulls, Cows );
void UBullCowCartridge::GetBullCows( const FString& Guess, int32 BullCount, int32 CowCount ) const
{
BullCount = 0;
CowCount = 0;
for( int32 GuessIndex = 0; GuessIndex < Guess.Len( ); GuessIndex++ )
{
if( Guess[ GuessIndex ] == HiddenWord[ GuessIndex ] )
{
BullCount++;
continue;
}
for( int32 HiddenIndex = 0; HiddenIndex < HiddenWord.Len( ); HiddenIndex++ )
{
if( Guess[ HiddenIndex ] == HiddenWord[ HiddenIndex ] )
{
CowCount++;
}
}
}
Here is the error Unreal 4.22 returns upon compiling:
\...\bullcowcartridge.cpp(102) : error C4700: uninitialized local variable 'CowCount' used
\...\bullcowcartridge.cpp(102) : error C4700: uninitialized local variable 'BullCount' used
Now I already know they’re uninitialized, & they aren’t receiving the values passed by the GetBullCows function, but I want to understand why this is. I’ve gone over the tutorial many times & skipped back & forth, & I can’t seem to find the solution.
Any help is appreciated, thank you for your time.