Re: Function definitions
Re: Function definitions
- Subject: Re: Function definitions
- From: Robert Martin <email@hidden>
- Date: Sat, 8 Apr 2006 19:00:00 -0400
It's declared in the header so that other files can reference it by
including the header. It's defined in the implementation file so the
compiler can map the code it generates to the function's name. Hard
to figure out a simpler way of getting this done.
On Apr 8, 2006, at 6:44 PM, Jonathan wrote:
Hi--
I'm having a hard time getting my head around one of the concepts
in C. If a
function is already defined in the header file, why does it need to be
defined again in the .c?
For example, if I put this in the header file:
int sum (int value1, int value2);
Why do I need to restate it when defining the function
implementation again
in the .c:
int sum (int value1, int value2)
{
return (value1 + value2);
}
Isn't one or the other just superfluous?
Best,
Jonathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40nyc.rr.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden