Answers for "c++ start a thread inside a class"

C++
0

c++ thread incide class

#include <iostream>
#include <thread>

class foo
{
public:
    void make_foo_func_thread()
    {
        t=std::thread(&foo::foo_func, this);
        t.join();
    }

private:
    std::thread t;
    void foo_func() { std::cout << "Hellon"; }
};

int main()
{
    foo f;
    f.make_foo_func_thread();
}
Posted by: Guest on October-09-2020

Code answers related to "c++ start a thread inside a class"

Browse Popular Code Answers by Language