|
-
June 30th, 2011, 03:29 PM
#1
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
-
June 30th, 2011, 04:00 PM
#2
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
-
June 30th, 2011, 04:21 PM
#3
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.
-
June 30th, 2011, 04:25 PM
#4
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|