Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 什么是;typedef void(*task)()类型;做_C++_Typedef - Fatal编程技术网

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了。

谢谢,现在它有意义了。