在C函数重载 [英] function overloading in C

查看:113
本文介绍了在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.

推荐答案

有几种可能性:


  1. 的printf风格的函数(类型作为参数)

  2. 的OpenGL风格的函数(类型函数名)

  3. 的C ++Ç子集(如果你能使用C ++编译器)

这篇关于在C函数重载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆