class - Using rand() and srand() in C++ -
i made class function returns randomly generated pair<int, int>
represent coordinate pair. @ beginning of function have srand(time(null))
, use rand() % 50
random number pair. works great...as long have 1 object of that. if have 2 different objects of class , call function each object (by mean trying generate 2 different random coordinates 2 different objects of class), returns exact same coordinate pair each object. in retrospect, can understand why happens -- because i'm getting random number based off of current time, right? method should use return random pair every time call class's function?
Comments
Post a Comment