64,654
社区成员
发帖
与我相关
我的任务
分享
#include <thread>
#include<iostream>
#include <unistd.h>
using namespace std;
class AAA
{
public:
AAA();
~AAA();
int test;
};
AAA::AAA()
{
}
AAA::~AAA()
{
}
void new_pthread(AAA& a)
{
cout << a.test << endl;
}
int main(void)
{
AAA aaa;
aaa.test = 123;
thread t(new_pthread, aaa);
t.join();
return 0;
}
#include <thread>
#include <iostream>
#include <unistd.h>
using namespace std;
class AAA
{
public:
AAA();
~AAA();
int test;
};
AAA::AAA()
{
}
AAA::~AAA()
{
}
void new_pthread(AAA* a)
{
cout << a->test << endl;
}
int main(void)
{
AAA aaa;
aaa.test = 123;
thread t(new_pthread, &aaa);
t.join();
return 0;
}