0

Function overloading in c ?

if no then how printf takes two parameters also explain yes. Thank you

14th Dec 2016, 12:35 PM
Vipul Walia
Vipul Walia - avatar
8 Réponses
+ 1
C++ does it (C doesn't). And...this has been asked, e.g.: https://www.sololearn.com/Discuss/99146/why-would-i-want-to-overload-function Search SoloLearn for 'overloading' to see many more.
14th Dec 2016, 1:19 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
i think i need to look into the addition of the _Generic keyword in C11. (supported in GCC since version 4.9). (Overloading isn't truly "built-in" in the fashion shown in the question, but it's dead easy to implement something that works like that.) _Generic is a compile-time operator in the same family as sizeof and _Alignof. It is described in standard section 6.5.1.1. It accepts two main parameters: an expression (which will not be evaluated at runtime), and a type/expression association list that looks a bit like a switch block. 
14th Dec 2016, 1:35 PM
Vipul Walia
Vipul Walia - avatar
0
i gone through that man . Depressingly i need one or two line explanation for that for call interview
14th Dec 2016, 1:03 PM
Vipul Walia
Vipul Walia - avatar
0
Shortly, there is no function overloading in C.
14th Dec 2016, 1:11 PM
Ondřej Doněk
Ondřej Doněk - avatar
0
But you can suggest using C++ :) while GCC is everywhere.
14th Dec 2016, 1:12 PM
Ondřej Doněk
Ondřej Doněk - avatar
0
But anyway I wish you luck!
14th Dec 2016, 1:12 PM
Ondřej Doněk
Ondřej Doněk - avatar
0
@Kirk i want to know in context of c not c++
14th Dec 2016, 1:32 PM
Vipul Walia
Vipul Walia - avatar