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