Re: const function() !!??
From: Andrey Tarasevich (andreytarasevich_at_hotmail.com)
Date: 12/30/04
- Next message: Joona I Palaste: "Re: Recommended style"
- Previous message: Kenny McCormack: "Is this standards compliant?"
- In reply to: Sundar: "const function() !!??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Dec 2004 10:46:29 -0800
Sundar wrote:
> Do we have something called a const function ? I thought applying the
> 'const' specifier to a function is meaningless...
You can't apply the 'const' specifier to a function in C. That would be
a syntax error.
> but when i tried
> defining a const function it worked !!
> like...
> const int func(int a)
> {
> int b;
> .....
> return b;
> }
This is not a 'const' function. In accordance with C syntax, this
'const' qualifier is applied to the return type of the function. I.e.
this function return type is 'const int'.
Syntactically, a naive attempt to apply a 'const' qualifier to a
function would look as follows
int (const func)(int a)
but this simply won't compile.
-- Best regards, Andrey Tarasevich
- Next message: Joona I Palaste: "Re: Recommended style"
- Previous message: Kenny McCormack: "Is this standards compliant?"
- In reply to: Sundar: "const function() !!??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|