<分区>
我的代码是这样的:-
#include <iostream>
#include <thread>
using namespace std;
void swapno (int &a, int &b)
{
int temp=a;
a=b;
b=temp;
}
int main()
{
int x=5, y=7;
cout << "x = " << x << "\ty = " << y << "\n";
thread t (swapno, x, y);
t.join();
cout << "x = " << x << "\ty = " << y << "\n";
return 0;
}
此代码无法编译。谁能帮我弄清楚为什么?
不仅是这段代码,还有 this 中的代码也未能通过引用发送 std::unique_ptr
。 std::thread
有什么问题?