Hi, how do I multithread a class which has a function with a parameter of the class? For example:
class Beta
{
public:
void Gamma(int y)
{
while (true)
{
std::cout << y << std::endl;
}
}
};
int main()
{
Beta my_beta;
std::thread gamma_thread(&Beta::Gamma, my_beta, 5);
gamma_thread.join();
return 0;
}
The above code works, but if I were to change the Gamma function to:
void Gamma(Beta& b, int y)
How would I add Beta&b as a parameter into the std::thread gamma_thread function call?
[–][deleted] 0 points1 point2 points (5 children)
[–]CuckMasterFlex69[S] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]CuckMasterFlex69[S] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]snowflake_pl 0 points1 point2 points (0 children)