If I run this Bunny1 and Bunny2 will be equal. Because I call the funcion so quickly that srand() as no time to chage
File 1
using namespace std;
int main()
{
bunny start1;
bunny start2;
system("Pause");
return 0;
}
File 3 - All The Action Take Place Here
#include "stdafx.h"
#include "bunny.h"
bunny::bunny()
{
int Number;
int n;
string buffer;
srand(GetTickCount()); // The see is here!! // It cant be here.
newAge = 0; // Age
newSex = static_cast<bool>(rand() % 2); // True = MALE // False = Female
if ((rand() % 100 + 1) <= 2) {newRadioactive = true;} // 2 % chance of mutant
}
Aucun commentaire:
Enregistrer un commentaire