Re: Function definitions
Re: Function definitions
- Subject: Re: Function definitions
- From: Jonathan <email@hidden>
- Date: Sat, 08 Apr 2006 17:58:54 -0700
- Thread-topic: Function definitions
Hi, Robert--
Couldn't you just do the declare in the header:
int sum (int value1, int value2);
and then just use the function you just declared in the function
implementation:
sum ()
{
return (value1 + value2);
}
?
Best,
Jonathan
on 4/8/06 4:00 PM, Robert Martin at email@hidden wrote:
> 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