use of a class - get random nos - "playback" a given particular random sequence

This is a discussion on use of a class - get random nos - "playback" a given particular random sequence within the C++ Programming forums, part of the General Programming Boards category; I am very new to this & don't understand -- basic explanation will be helpful.. The class should be capable ...

  1. #1
    Unregistered
    Guest

    Unhappy use of a class - get random nos - "playback" a given particular random sequence

    I am very new to this & don't understand -- basic explanation will be helpful..

    The class should be capable of playing back the random numbers given a particular sequence.. so a seed is needed but how do you write the code so it remembers/keeps track of that seed & the rand nos w/ an instance of the class.

    I'm sooo confused.

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Have the constructor or a member function take a seed, and another function to generate a certain amount of numbers based on this seed. When you want to replay the numbers, re-seed using the member function and then call the function to generate the numbers again.

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    don't quite get what u r asking. U could always use an array to record the results and have the user input the seed.

  4. #4
    Unregistered
    Guest
    i'm a real newbie so pardon me if i confuse anyone..
    but basically my class ARandom have these c'tors:

    ARandom::set seed(unsigned seed)
    {
    theseed = seed;
    SRand(theseed);

    return;
    }

    unsigned ARandom::get seed(void)
    {
    return theseed;
    }

    Now i dunno how & where to get the Random number & what my main function will say..

    thanks for any help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 08:10 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  3. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM
  5. Difficulty superclassing EDIT window class
    By cDir in forum Windows Programming
    Replies: 7
    Last Post: 02-21-2002, 04:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21