You have multiple problems in your program
- As your compile error says, you need to pass the address of the function
&Beta::Gamma
.
- You need to pass the object as a parameter considering
this
is an implicit parameter of a member function
Modified source
#include
#include
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;
}