I'm assuming there's an easy answer to this question. I want to first define a thread as a member variable of a class, and then later start this thread in a different function.
For example:
The header file:
#include<thread>
class Foo{
public:
void threaded_method();
void start_thread();
private:
std::thread m_thread;
};
Cpp file:
void Foo::start_thread(){
m_thread = std::thread(threaded_method);
}
Although the above does not work, thoughts?