Re: const qualifier - in declaration, definition or both?
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Fri, 31 Aug 2007 10:31:35 -0400
Asbjørn Sæbø wrote:
^^^^
Suppose I have a function that takes a pointer as its input, but
does not change what the pointer points to. In that case, the
const qualifier can be used to indicate that the variable pointed
to is not changed. But should this const qualifier be used in
the function declaration, the function definition, or both?
Example:
In .h-file
int foo(const int *bar);
In .c-file
int foor(const int *bar)
Assuming that should read 'foo'
{
return *bar + 2;
}
That's just fine. The return value is delivered, and anything done
to it will not disturb the original foo.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com
.
- References:
- const qualifier - in declaration, definition or both?
- From: Asbjørn Sæbø
- const qualifier - in declaration, definition or both?
- Prev by Date: Re: size_t problems
- Next by Date: Macro inside a string
- Previous by thread: Re: const qualifier - in declaration, definition or both?
- Next by thread: Macro inside a string
- Index(es):
Relevant Pages
|