Returning function pointer type

前端 未结 7 1986
心在旅途
心在旅途 2020-11-29 20:08

Often I find the need to write functions which return function pointers. Whenever I do, the basic format I use is:

typedef int (*function_type)(int,int);

fu         


        
7条回答
  •  孤街浪徒
    2020-11-29 20:29

    I think you've got three options:

    1. Stick with typedef. At the end of the day, it's typedef's job.
    2. Return void* and the casting it.
    3. Reconsider your software architecture. Perhaps you could share with us what you're trying to achieve and see if we can point you toward a better direction.

提交回复
热议问题