First time ever looking at anything C++ and the last thing I ever did programming-wise was a couple years of Java at college 10 years ago. Still, there are enough similarities to make educated guesses:
The first two lines define variables which are both integers - it sets the “difficulty” integer at 2 and the “maxDifficulty” integer at 10.
The “while” statement repeats over and over until the difficulty integer equals the maxDifficulty integer. It plays the game at a certain difficulty and then increments the difficulty by 1 each time. I don’t know exactly what the comments mean when they say “clears the failbit” or “discards the buffer” but my guess is it has something to do with binary bits and the math happening while you play the game.
I’m guessing the “std::cout” line is similar to the print line function in Java, where it displays that following message to the user playing the game.
I don’t know for sure what the “return 0” line does - maybe it’s just the line that terminates the function?