void Game::game() { _beginthread(Game::key_thread, 0, NULL); _beginthread(Game::timer_thread, 0, NULL); Sleep(10000000000000000000); }显示void(Game::*)(void*arg)类型的实参与_beginthread_proc_type类型的形参不兼容怎么修改
时间: 2024-02-25 11:59:43 浏览: 169
这个错误提示是因为 _beginthread 函数需要的参数类型是 _beginthread_proc_type,而 Game::key_thread 和 Game::timer_thread 是成员函数,需要通过指向成员函数的指针来调用。可以将成员函数改为静态成员函数来解决这个问题。以下是修改方案:
```
static void Game::key_thread(void* arg);
static void Game::timer_thread(void* arg);
void Game::timer_thread(void* arg) {
bool flag1 = false;
while (seconds >= 0)
{
int gewei, shiwei;
gewei = seconds % 10;
shiwei = seconds / 10;
putimage(1012, 600, &number[shiwei]);
putimage(1062, 600, &number[gewei]);
Sleep(1000);
seconds--;
if (flag == true)
{
flag1 = true;
break;//说明时间内走到了终点
}
if (shengmingzhi == 0)
{
break;
}
}
if (seconds < 0)
{
flag = false;
biaoji.time = true;
}
if (flag1 == false) endgame();
}
void Game::game() {
_beginthread(Game::key_thread, 0, NULL);
_beginthread(Game::timer_thread, 0, NULL);
Sleep(10000000000000000000);
}
```
将成员函数改为静态成员函数即可。
阅读全文