What I think the main() function does

First off the function sets the current difficulty of the game and then the maximum difficulty of the game. As to why I say current difficulty rather than starting difficulty which seems more appropriate I will explain on later.

The function then has a while statement that repeats as long as the current difficulty is smaller or equal to the maximum difficulty. When the while statement runs it does whatever is written and told to do in the “PlayGameAtDifficulty” function. Then I don’t know the part for the std::cins… I assume those two are there to make the game run properly/smoothly without possible bugs or errors. Now comes the parts where I will explain why I said current difficulty instead of starting difficulty; the while statement, after running the three codes elaborated above, increases the difficulty of the game therefore calling the difficulty integer starting difficulty a bit invalid.

Finally when the while statement stops repeating iteself because the current difficulty of the game has reached the max difficulty and the player has beaten it the std::cout code prints a complementing text to imply that the game is over.

Then function ends when the return 0 code is run which is necessary for a smooth exit for any code in C++.

What I’ve learned from Dan’s explanation:

I’ve learned what the std::cin technically does although I don’t understand them very well yet as to what they actually do. I’ve realized that when I explained the main() function I forgot to mention any kind of indentation so anyone else reading my explanation of the code without seeing it first would be extremely confused.

Next time when I explain codes I will make sure to mention indentations for clarity and detail.

Privacy & Terms