I'm struggling to create a little Blackjack console game in C++. I've written almost the whole code (you may find it pretty messy, but I have like no experience in this kind of things). It works, but not completely. As you know (or no) when your cards' value equals 21 you win the game, and if you have more - you lose. In my project the game never stops, When you get 21, when dealer gets 21 or when you pass 21, the game is still on. Maybe I forgot to add something and I'd be really pleased if you could point it out! :) CODE
In your main()
function, you are defining a new local state variable:
GAMESTATE GSState = GAME;
that shadows the global one that your other classes are updating to indicate the end of the game.
You should have only assigned it a value:
GSState = GAME;
With gcc, you can compile with the flag -Wshadow
if you want the compiler to warn you about this kind of potential errors (but there might be a lot of false positive).