class CTest
{
public:
CTest(){}
~CTest(){}
public:
int Func(const char * szBuf,int n,bool &bret)
{
std::cout << szBuf << "n="<<n<<std::endl;
if(n % 2 ==0)
{
bret = true;
}
return 0;
}
void Action()
{
int n = 4;
bool bret = false;
//取地址变量,需要用 ref
std::thread t(&CTest::Func, this, "hello, world",n,ref(bret));
t.join();//等待线程完成
}
};
int _tmain(int argc, _TCHAR* argv[])
{
CTest obj;
obj.Action();
}