My Updated B&C Game with a Couple Questions about Section 2

Hi Everyone!

I found this section a bit more challenging than I expected, but nevertheless I’m keeping things moving forward into Section 3. Before I continue, I’d like to submit my updated version of Bulls and Cows. I added a difficulty selector that allowed the user to pick between three difficulties that update the word the user guesses and the number of tries they get. Probably a simple task for most, but I was struggling a bit and wanted to do it without help first. I went back into a couple of lessons and powered through it and got it working. I feel like I could’ve done it with less code, but the things I tried to do kept giving me errors. I have some questions at the bottom if anyone’s able to help. So here’s my code. Let me know what you think:

Now for some questions I had:

  1. Why do we include #pragma once on every page? I had it in my FBullCowGame.h file and everything seemed to work just fine since it was included in the other two.

  2. How does FBullCowGame.cpp even work? It might seem like a silly question, but it isn’t included in main.cpp like FBullCowGame.h is. I’m trying to follow the logic and not seeing how the class methods are getting called out of it from main.cpp or how the header knows how to find them. Is it just a given that the header is all you need?

  3. Why couldn’t I change MyHiddenWord from an enum class method I made? It worked for changing the difficulty, but I had to make new void Reset() methods.

That’s it for now. I’m getting the hang of it, but have a lot of work to do. Let me know what you think!

Mike

Privacy & Terms