I use Reference(&) here,but the a didn't change.Why? While i use Pointer(*) the value have changed.
int all=0;
void call_from_thread(int & a)
{
a = 5;
}
int main()
{
thread s = thread(call_from_thread, all);
s.join();
return 0;
}
Another program,in this case, i also use Reference(&),but the value have changed. Why the value a in thread didn't change?
void Func3(int &x)
{
x = x + 10;
}
int main() {
int n = 0;
Func3(n);
cout << “n = ” << n << endl; // n = 10
}