Returning function pointer type

前端 未结 7 1977
心在旅途
心在旅途 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:30

    This is a stupid example, but it's simple and it does not give errors. It's just about declaring static functions:

    #include 
    #include 
    
    void * asdf(int);
    static int * hjkl(char,float);
    
    main() {
      int a = 0;
      asdf(a);
     }
    
    
    void * asdf(int a) {return (void *)hjkl; }
    static int * hjkl(char a, float b) {int * c; return c;}
    

提交回复
热议问题