laniik said:
ahh. ok i understand that, but how would I initialize the values of the
vector in a loop? can i have a for loop just in the general context of
the c file?
i need to have a for loop that fills the spots because it is about 1024
in length so doing it by hand would be rediculous.
thanks!
Well, there are many ways to attack this. Whatever
I recommend, someone else will suggest another approach.
ONE approach is to have a static function in your class
whose sole function is to init the shared array. Then
in your main(), explicitly call that static function
before any instances of your class are created. This
won't work if instances of the class are created before
main() is invoked (if you have global instances of your
class that are constructed before main()).
Another approach is to have a member function in your
class that is called by ALL of the class constructors.
This member function would init the array. In this
approach the member function that inits the array must
use some serialization mechanism to ensure that the
array is init'ed only once (mutex, semaphore, etc) and
that concurrent calls to it from multiple threads do
not mangle the array.
In any approach, you might want a boolean static member
of your class that denotes whether or not the array has
been initialized yet. The code that inits tha array
would set this static boolean to 'true'.
There are other ways to do it...
Regards,
Larry