请教老师一个问题
来源:10-18 多线程银行存取款案例
remembers
2020-08-15
#include <thread>
#include <iostream>
using namespace std;
struct MyStruct
{
void func()
{
cout << "func" << endl;
}
};
void test(MyStruct myStruct)
{
myStruct.func();
}
int main()
{
MyStruct myStruct;
thread t(test, myStruct);
t.join();
return 0;
}
把上面的 test 函数的参数列表修改成 test(MyStruct& myStruct) 就编译不通过,这是怎么回事呢 ?
写回答
1回答
-
报什么错,这里传递引用参数需要使用ref,请仔细对照视频内容修改。
112020-08-16
相似问题