So…
As the title says, in the video at 1:15 it is said the struct is being created in the FBullCowGame.h header file, because we want it to be used by the “accompanying” (my way of saying it) FBullCowGame.cpp file, and NOT by the main.cpp file. Well, could we technically still use it on the main.cpp since it has #include “FBullCowGame.h” at the top?
I thought #include were like copying and pasting the whole contents, so it should include anything and everything from the .h files right? Even the top part stuff (and not only the methods)?
1 Like
Correct.
3 Likes
Hello @berickphilip and dear Community,
you are able to instantiate the struct BullCowCount
from the file FBullCowGame.h
because you included it on top with using the command #include "FBullCowGame.h"
.
#include "pch.h"
#include "FBullCowGame.h"
using int32 = int;
BullCowCount myCount;
FBullCowGame::FBullCowGame() { Reset(); }
int32 FBullCowGame::GetMaxTries() const { return this->MyMaxTries; }
int32 FBullCowGame::GetCurrentTry() const { return this->MyCurrentTry; }
void FBullCowGame::Reset()
{
constexpr int32 MAX_TRIES = 8;
MyMaxTries = MAX_TRIES;
const FString HIDDEN_WORD = "planet";
MyHiddenWord = HIDDEN_WORD;
MyCurrentTry = 1;
return;
}
bool FBullCowGame::IsGameWon() const
{
return false;
}
bool FBullCowGame::CheckGuessValidity(FString)
{
return false;
}
// receives a VALID guess, incriments turn, and returns count
BullCowCount FBullCowGame::SubmitGuess(FString)
{
// increment the turn number
this->MyCurrentTry++;
// setup a return variable
BullCowCount BullCowCount;
// loop through all letters in the guess
// compare letters against the hidden word
return BullCowCount;
}
Kind regards
Kevin
1 Like