I am using the following code
class foo
{
private:
int val;
public:
void someMethod()
{
std::cout << val ;
}
foo()
{
val = 12;
boost::thread t(&foo::someMethod,this);
}
};
I am accessing this class as:
foo f;
Now from what I understand is that all the member variables of f are created on the stack. From this thread I understand that threads share the same heap of the program but each thread has its own stack space. I wanted to know how someMethod() running in its own thread have access to the class variable.