Boost logo

Boost Users :

From: Peter (yg-boost-users_at_[hidden])
Date: 2002-06-17 23:08:57

Is it possible to pass a pointer of a class member function into a thread ??
I have no problems passing functions (or pointers to functions rather) which
are not members of any classes. However when I try to pass member functions,
I get compile errors. I am using MSVS 6.0 on win 2000.

The following is a simplified model of my situation. I am trying to create a
thread inside a function of one class and pass into it, a pointer of a
member function of another class:

// all necessary includes;

class testClass1
    // constructor
    testClass1() { // init code}
    ~testClass1() {}

    void fun1() { // some code}


class testClass2
  testClass2() { // init code}
    ~testClass2() {}

    void fun2()
        // some code..

        boost::thread myThread(&object1.fun1) ; // PROBLEM HERE

        // more code...

    testClass1 object1;

int main(int argc, char **argv)

    testClass2 class2;

    // some code...


    // more code....

    return 0;

Any help would be greatly appreciated. Thanks in advance.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at