dean wrote:
> We were working through one of Sutter's books this lunch time, and it
> came about that you can put a function:
>
> void f(int i); // in the header file
>
> and
>
> void f(const int i) {} // as the definition.
>
> My question is: is that correct? Isn't the type const int different
> from just int?
Well, there's no definitive answer to that question within the C++98
language specification. It is not clear on this, which is recognized in
defect report #140
http://www.open-std.org/jtc1/sc22/wg...fects.html#140
According to the original intent, function declarations should be
matched to each other in accordance with their adjusted parameter lists,
i.e. after (not before) all array and function types are replaced with
corresponding pointer types and all top-level cv-qualifiers are removed.
The original version of the standard failed to address this
"before/after" ambiguity.
I don't know when the changes suggested by DR#140 were incorporated into
the document, but I can see them in N2461.
The compilers followed the intended approach from the very beginning, so
you can use it safely.
--
Best regards,
Andrey Tarasevich