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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -