In my program, I have an object the global cpp file, that takes an integer as an argument.
//In global header
extern Object example;
//In global cpp file
Object example( (rand() % 6) );
I want a random number to be generated to the object's argument, but the seed does not reach the global variable, as the seed created in another cpp file, which is called later in the main.
My main problem is the random seed does not reach argument of the object in global.cpp, but I also put there for a specific reason, which involves threads.
My main question is: Can a random seed reach a global variable? if yes, please tell me how
(ALSO if yes, the next question is irrelevant)
But if it's not possible, this question regards to threads and the where to create the object. The object class calls a function in run thread, and calls a different function on another thread, such as the following:
//Thread A
int thread(void *data)
{
example.showimage();
return 0;
}
//ThreadB
int thread(void *data(
{
example.moveimage();
return 0;
}
I want this kind of functionality between the 2 threads, but is there a way to achieve this without creating the object in globals?