
12 Mar
2009
12 Mar
'09
4 p.m.
Hi, I have problems creating a thread. This is an example i found: #include <boost/thread/thread.hpp> #include <iostream> void hello() { std::cout << "Hello world, I'm a thread!" << std::endl; } int main(int argc, char* argv[]) { boost::thread thrd(&hello); thrd.join(); return 0; } What if i want to create a thread outside of main (in a class) like this: "myClass.h" class MyClass { public: hello(); myFunction(); }; "myClass.cpp" MyClass::hello() { std::cout << "Hello world, I'm a thread!" << std::endl; } MyClass::myFunction() { boost::thread thrd(&hello); thrd.join(); } This does not work and i get the compile error: '&' : illegal operation on bound member function expression