Help! Dont understand why are we using this

Hey can anyone help me with section 2, lecture 32?
I have understand everything except the part where we put this code in main: FBullCowCount BullCowCount = BCGame.SubmitGuess(Guess);
I have restarted the course 3 timed now because i dont fully understand everything that section 2 teaches… is it appropriate to learn everything in section 2? Thanks Ben and the community!

Hi @Erifaj,

Go back and have a quick look at the part where you created the structure FBullCowCount, I think it may help you get this. The structure definition looks like this:
struct FBullCowCount { int32 Bulls = 0; int32 Cows = 0; };

Attempt at explanation; prone to be filled with rookie mistakes

FBullCowCount is a structure of variables of integer type. This lets you address the two different integer variables by referring to them by the name, BullCowCount. So another way to do this:

FBullCowCount BullCowCount = BCGame.SubmitGuess(Guess);

Could be something like this:
int BullCount = BCGame.BullsWeCount(Guess); int CowCount = BCGame.CowsWeCount(Guess);
…in this example, we have the imaginary functions BullsWeCount() and CowsWeCount.

These functions would be pretty much identical, looping through Guess and counting the number of hits and misses (Bulls and Cows). Because we are using the FBullCowCount structure to group the integer variables together, we are letting ourselves be a little lazy (in a good way), as we don’t have to write duplicate functions. Also, we count both the hits and the misses while looping the letters of the word only once, meaning the program performs this roughly twice as fast.

When it comes to a rather simple program like this, I am pretty sure the performance impact is not something anyone would notice, but this element of the course serves as a valuable lesson nontheless.

Edit: Added some whitespace for readability.

Privacy & Terms