Ok so I'm trying to write a yatzy game for my c++ class
but I'm really unsure almost clueless about how to manage with the part when to save dices and keep on rolling.
here is my very unfinished code!
Line 10: That's not the best place to call srand(). srand() should be called once at the beginning of main.
Line 6,13: Using the same variable name is confusing.
Line 25: Your vector of dice rolls goes out of scope.
As for keeping dice, if the answer is no, set the element of the dice array to 0. Then when you re-roll the dice, reroll only those entries where the value of the die is 0. You need to fix your dice vector going out of scope before this will work.
You're inconsistent with your use of yes/no. In one place it is j/n, in others it is 1/2. Be consistent. Consider writing a function that prompts for y/n and returns a bool result.
Line 6: PlayerOne is an uninitialized variable (garbage). Line 41, you're using this uninitialized variable as a termination condition.
Line 35: numKeep is an uninitialized variable. Line 50, you're incrementing this uninitialized variable.
Edit:
I would be inclined to have three classes. A Game class (yazzie), a Player class and a Hand class. A Game has one or more Players. A player has a score and a Hand. A Hand has 5 dice.
You might search this forum for poker games. There are several good examples that should give you some good ideas about scoring a Yahtzee hand since it's very similar to scoring a poker hand.