在学习c++ thread时候遇到一个小小的疑惑。功能都可以实现,但是区别是一个直接引用对象,另一个是获取对象的地址,
向大家请教一下这2者有什么区别?
源码:
#include<iostream>
#include<thread>
using namespace std;
class mm
{
public:
void printf()
{
cout << "nihao" << endl;
}
};
int main()
{
mm a;
thread thread1(&mm::printf,&a);
//thread thread1(&mm::printf,a);//这一行没有添加取地址符号
thread1.join();
}