I'm certain that this is a simple design error, but I'm not sure where to go with it anyway.
I'd like to spawn a thread from an instance of a class. Specifically:
class Foo
{
public:
void bar() { /*do stuff*/ }
};
Usage:
int main()
{
Foo foo_instance();
std::thread foo_thread(foo_instance.bar);
foo_thread.join();
return 0;
}
When I compile the more detailed version of this, I get invalid use of non-static member function
referring to the line std::thread foo_thread(foo_instance.bar);
.
So, what am I misunderstanding here? I'd like the object to be initialized and "functional" before I spin it off into a thread, but clearly I'm not using the tools correctly.