gpt4 book ai didi

c++ - 有人可以解释以下奇怪的函数声明吗?

转载 作者:搜寻专家 更新时间:2023-10-31 00:22:06 25 4
gpt4 key购买 nike

std::thread f()
{
void some_function(); // <- here
return std::thread(some_function);
}

std::thread g()
{
void some_other_function(int); // <- here
std::thread t(some_other_function,42);
return t;
}

最佳答案

行如下:

void some_function();

只需声明一个稍后定义的函数。函数不一定必须在函数范围之外声明。

关于c++ - 有人可以解释以下奇怪的函数声明吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3714221/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com