I have this dice game and it has the user input the number of sides on the di. When I debug it it prints the cout statement twice and I am confused. Where is my mistake? (Also, I borrowed this from someone else and it is their work)
Because, roll() is called once in the class' constructor, so its called once when you create G1. Then again you call G1.roll(). So you see it two times. To fix this just remove G1.roll().
Also since you are using srand() and rand() you need to add #include <cstdlib> too.