How to achieve function overloading in C?

前端 未结 14 2284
清歌不尽
清歌不尽 2020-11-22 03:16

Is there any way to achieve function overloading in C? I am looking at simple functions to be overloaded like

foo (int a)  
foo (char b)  
foo (float c , i         


        
14条回答
  •  情歌与酒
    2020-11-22 04:22

    In the sense you mean — no, you cannot.

    You can declare a va_arg function like

    void my_func(char* format, ...);

    , but you'll need to pass some kind of information about number of variables and their types in the first argument — like printf() does.

提交回复
热议问题