<分区>
Possible Duplicate:
function overloading in C
ANSI C 不允许函数重载(我不确定 C99)。
例如:
char max(char x, char y);
short max(short x, short y);
int max(int x, int y);
float max(float x, float y);
不是有效的 ANSI C 源代码。
应该使用哪种技术(或想法)来解决 ANSI C 中的函数重载问题?
注意:
一个答案是重命名函数,但是应该使用哪种模式来重命名,函数名称仍然是'good function name'?
例如:
char max1(char x, char y);
short max2(short x, short y);
int max3(int x, int y);
float max4(float x, float y);
对于 max
函数名来说不是一个好的命名。