c 2b 2b thread incide class

Solutions on MaxInterview for c 2b 2b thread incide class by the best coders in the world

showing results for - "c 2b 2b thread incide class"
Emelie
11 Oct 2017
1#include <iostream>
2#include <thread>
3
4class foo
5{
6public:
7    void make_foo_func_thread()
8    {
9        t=std::thread(&foo::foo_func, this);
10        t.join();
11    }
12
13private:
14    std::thread t;
15    void foo_func() { std::cout << "Hello\n"; }
16};
17
18int main()
19{
20    foo f;
21    f.make_foo_func_thread();
22}
23