阅读背景:

指针和引用之间的区别作为线程参数。

来源:互联网 

This is the example:

这是例子:

#include<iostream>
#include<thread>
using namespace std;

void f1(double& ret) {
   ret=5.;
}

void f2(double* ret) {
   *ret=5.;
}

int main() {
   double ret=0.;
   thread t1(f1, ret);
   t1.join();
   cout << "ret=" << ret << endl;
   thread t2(f2, &ret);
   t2.join();
   cout << "ret=" << ret << endl;   
}
#include<iostrea



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: