#include <iostream> #include <ctime> using namespace std; class massive { private: int b[4]; public: massive() { srand(time(0)); for (int i = 0; i < 4; i++) { b[i] = 1 + rand() % 10; cout << b[i] << " "; } cout << "\n"; } }; int main() { massive a; massive b; return 0; } Why when executing the code, both arrays are constantly initialized (or, at least, displayed on the screen) with the same numbers? https://www.onlinegdb.com/edit/B1wiCeG2m

time(0)returns the time in seconds, so in almost all launches the value passed tosrand()will be the same. - avp