如何在 C 中实现函数重载? [英] How to achieve function overloading in C?
本文介绍了如何在 C 中实现函数重载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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 , int d)
I think there is no straight forward way; I'm looking for workarounds if any exist.
解决方案
There are few possibilities:
- printf style functions (type as an argument)
- opengl style functions (type in function name)
- c subset of c++ (if You can use a c++ compiler)
这篇关于如何在 C 中实现函数重载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文