2013-02-09 2 views
0

은이 질문은 부분적으로 여기"typedef void (* task)()"는 무엇을합니까?

What does "typedef void (*Something)()" mean 대답하지만 대답은 나에게 완전히 명확하지 않다. 내가

이 이
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_pool(unsigned int num_threads, (*task)() tbd) { 
     for(int i = 0; i < num_threads; ++i) { 
     the_pool.push_back(thread(tbd)); 
     } 
    } 

아마도 구문 오류이므로 가능하지 않습니다. 네가 나를 위해 일을 정리해주기를 바란다. http://www.thesaguaros.com/openmp-style-constructs-in-c11.html

답변

2

에서이처럼

코드 예제입니다 :

입니다
thread_pool(unsigned int num_threads, void (*tbd)()) 

이 유형은 함수 서명하는 유일한 "단어"는 "무효." typedef를 더 이상 사용하지 않기 때문에이 예에서는 typedef 이름 "task"가 사라집니다.

+0

감사합니다. 이제는 의미가 있습니다. –