C++ 什么是;typedef void(*task)()类型;做
这个问题在这里得到了部分回答 但我并不完全清楚答案 如果我写C++ 什么是;typedef void(*task)()类型;做,c++,typedef,C++,Typedef,这个问题在这里得到了部分回答 但我并不完全清楚答案 如果我写 typedef void (*task) (); 它是如何扩展的 thread_pool(unsigned int num_threads, task tbd) { for(int i = 0; i < num_threads; ++i) { the_pool.push_back(thread(tbd)); } } thread\u池(未签名的int num\u线程,任务待定)
typedef void (*task) ();
它是如何扩展的
thread_pool(unsigned int num_threads, task tbd) {
for(int i = 0; i < num_threads; ++i) {
the_pool.push_back(thread(tbd));
}
}
thread\u池(未签名的int num\u线程,任务待定){
对于(int i=0;i
看起来像这样吗
thread_pool(unsigned int num_threads, (*task) () tbd) {
for(int i = 0; i < num_threads; ++i) {
the_pool.push_back(thread(tbd));
}
}
thread_池(unsigned int num_threads,(*task)()待定){
对于(int i=0;i
可能不是,因为这是一个语法错误。我希望你能帮我把事情弄清楚
代码示例来自它是这样的:
thread_pool(unsigned int num_threads, void (*tbd) ())
也就是说,类型是函数签名,其中唯一的“单词”是“void”。在本例中,typedef名称“task”消失,因为我们不再使用typedef了。谢谢,现在它有意义了。