void game是什么意思
时间: 2023-10-24 20:05:12 浏览: 82
"void game"不是一个通用的编程术语或常用术语,因此没有一个明确的含义。通常情况下,"void"在编程中是一种数据类型,表示不返回任何值的函数或方法。而"game"则是游戏的意思。因此,"void game"可能是指一种没有返回值的游戏,或者是某个特定的程序中定义的一个函数或方法的名称。但具体含义还需根据上下文来确定。
相关问题
void Game::game() { _beginthread(&Game::key_thread, this, NULL); _beginthread(&Game::timer_thread, this, NULL); Sleep(10000000000000000000); }这样修改之后仍然编译不通过请问是什么问题
根据你提供的信息,我猜测你可能遇到了函数指针类型不匹配的问题。`_beginthread`的第一个参数应该是一个函数指针,而`key_thread`和`timer_thread`是成员函数,需要通过类的对象来调用。
你可以将成员函数变为静态函数,或者使用`std::bind`或lambda表达式来将类的对象和成员函数绑定,例如:
```
void Game::game() {
_beginthread(&Game::key_thread_static, 0, this);
_beginthread(&Game::timer_thread_static, 0, this);
Sleep(10000000000000000000);
}
void Game::key_thread_static(void* arg) {
Game* game = static_cast<Game*>(arg);
game->key_thread();
}
void Game::timer_thread_static(void* arg) {
Game* game = static_cast<Game*>(arg);
game->timer_thread();
}
```
或者使用`std::bind`:
```
void Game::game() {
_beginthread(std::bind(&Game::key_thread, this, std::placeholders::_1), 0, NULL);
_beginthread(std::bind(&Game::timer_thread, this, std::placeholders::_1), 0, NULL);
Sleep(10000000000000000000);
}
```
这里使用了`std::placeholders::_1`来占位符,表示传入的参数不需要使用。
void Game::game() { _beginthread(Game::key_thread, 0, NULL); _beginthread(Game::timer_thread, 0, NULL); Sleep(10000000000000000000); }显示void(Game::*)(void*arg)类型的实参与_beginthread_proc_type类型的形参不兼容怎么修改
这个错误提示是因为 _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);
}
```
将成员函数改为静态成员函数即可。