Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ initializing a thread with a public function of a class


class myFunc
{
public:
  void pubFunc1()
  {
    cout << "publicFunc1 of myFunc class called" << endl;
  }
};

/*****************************************************/

myFunc myFunc1;

thread thread1(&myFunc::pubFunc1,myFunc);

if (thread1.joinable())
{
	thread1.join();
}
 
PREVIOUS NEXT
Tagged: #initializing #thread #public #function #class
ADD COMMENT
Topic
Name
5+3 =