Boost logo

Boost :

Subject: Re: [boost] To create a boost thread
From: Filip Klasson (filkl784_at_[hidden])
Date: 2009-03-13 03:29:43


Ohh sorry i didnt know that. Thanks all for the help!

2009/3/12 Herve Bronnimann <hervebronnimann_at_[hidden]>

> You're taking the address of a member function, which is a different type
> than what is expected.
>
> But fundamentally, this is not the appropriate mailing list. Try the boost
> users mailing list.
>
> Sent from my iPhone
>
>
> On Mar 12, 2009, at 12:00 PM, Filip Klasson <filkl784_at_[hidden]>
> wrote:
>
> 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
>> _______________________________________________
>> Unsubscribe & other changes:
>> http://lists.boost.org/mailman/listinfo.cgi/boost
>>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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