Today we came accross a problem concerning static member functions in an multithreaded environment. The question we asked ourselves and couldn\'t find a satisfying answer is: ar
No, a, b, and c are not static.
Here's a sample that illustrates this:
class Val
{
public:
Val() { cout << "Val" << this << endl; }
~Val() { cout << "~Val" << this << endl; }
int n_;
};
class A
{
public:
static int test()
{
Val a;
a.n_ = rand();
Val b;
b.n_ = rand();
Val c;
c.n_ = a.n_ + b.n_;
return c.n_;
}
};
int main()
{
srand(time(0));
for( int i = 0; i < 5; ++i )
{
cout << "Test = " << A::test() << endl;
}
return 0;
}