G
Guest
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)
{
return *bar + 2;
}
With kind regards
Asbjørn Sæbø
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)
{
return *bar + 2;
}
With kind regards
Asbjørn Sæbø