Boost logo

Boost :

Subject: Re: [boost] To create a boost thread
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-03-12 12:09:47


AMDG

Filip Klasson wrote:
> 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 expressio

Since hello is a member function, you need to pass this

boost::thread thrd(&MyClass::hello, this);

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk