I can't observe this pattern.
I don't understand, though, why it must be so compliated to pick a number [0, i]
Why not
Code:
RandomIndex = rand() % (i + 1);
Daved may be referring to the fact that if (i + 1) in above statement is not a factor of RAND_MAX, the results tend to be biased but I don't think it would make that much difference here.
Once you are happy with what the code does, you might also consider cleaning it up style-wise.
* No need for the #defines.
* Once you have set DeckSize in the constructor, use it instead of magic 52 everywhere.
* Seconds makes no sense as a member of Deck class. In fact you don't need a separate time_t variable for srand() anyway.
* In for statements such as this:
Code:
for (i; i < x; ++i)
the first expression (i
does absolutely nothing (except producing a compiler warning if you have warnings enabled. Therefore you can just omit it:
In C++, however, the loop counter is usually declared inside the for-expression:
Code:
for (int i = qqq; i < x; ++i)
* Consider making Card a separate class / struct. (This will also help you get rid of the ugly 2D array and switch to random_shuffle more easily.)
* Consider using std::vector instead of the raw array.