Hello. I had my first real contact with programming in this course. Because of that, I found more interesting to make a program in parallel to the Bulls & Cows game (which I’m making too). I believe making my own game without looking nowhere else could help me to learn more quickly.
My Bulls & Cows game is doing ok, but my other game that I named NFL Quiz, I’m having a little trouble. I know that we can’t use the same variable in two different functions. In this video (at 8:15), the teacher show us how to correct this but in my case I’m struggling a lot and aprecciate some help.
Lines 30 and 77 are my problem!
PS. The program is incomplete of course, don’t mind about the rest.
The simplest way to solve this is to take line 27:
constexpr int NUMBER = 7;
and put it in (for example) line 9. So that you declare it outside of the functions.
Then its a global variable and can be accessed by all your functions.
that’s dirty code though and shouldn’t be how you do it.
If you already know how to pass a parameter to a function use that way instead !
As a sidenode:
bool EndGame()
uses
return;
therefore it does not return a boolean, but it returns nothing ( void ) like IntroGame() and PlayGame().