enum random problem

#include<iostream>
#include<ctime>
#include<cstdlib>

using namespace std;
void help();

class Dice
{
public:
Dice();
int Roll();
char get();
enum picture {Fish=1,Shrimp,Crab,Chicken,Golden_Coin,Magic_Barrel};

};

Dice::Dice()
{
int Roll=0;
}

int Dice::Roll()
{
srand(time(NULL));
picture pict=picture(rand()%6+1);
return pict;
}

i have some problem with this code
for example:
Dice x;
a=x.Roll();
b=x.Roll();
both of them will get the same answer
is there anyway to make them have a different number ?

Call srand() once at the beginning of your program instead of every time you Roll() a die.
Topic archived. No new replies allowed.