In c , how come function may have several declarations but only one definition?
In c , how come function may have several declarations but only one definition? Can someone elaborate on that plz
Re: In c , how come function may have several declarations but only one definition?
Can you define "several declarations"? As far as I know, in both C and C++ functions can have only one declaration and definition.
Viggy
Re: In c , how come function may have several declarations but only one definition?
A declaration says "Such a thing exists." It doesn't matter how many times you say this, so long as you're consistent about the interface. (C++ doesn't even require that, since it allows function overloading.)
A definition says "This is what it is." If you say that multiple times, the linker will shrug in confusion about which one is really what it is.
Re: In c , how come function may have several declarations but only one definition?
Okay, if you look at the question that way, yes. :)
I read the OP's question, and thought of overloaded functions, who's declarations are not the same (even if the function name is).
Viggy