similar to what you have, but max is not 2...
Also, personally, I would use a vector for input, less error prone...
#include <algorithm>
#include <ctime>
class MyRandom
{
public:
ptrdiff_t operator() (ptrdiff_t max)
{
printf("max=%d-",(int)max);
return rand()%max;
}
};
int main ()
{
srand ( unsigned ( time (NULL) ) );
int numbers [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int size = sizeof(numbers)/sizeof(int);
MyRandom r;
std::random_shuffle (numbers, numbers+size, r);
return 0;
}