Leslaw Bieniasz <> wrote in
news

:
>
> Cracow, 13.03.2008
>
> Hi,
>
> Assuming that I want to pass a reference to a function, and
> make sure that the function will not make any changes to the object
> passed, is it necessary to declare two "const's" or only one, i.e.
> for example:
>
> void fun(const Type& const x);
This is illegal because references aren't objects and therefore can't be
const by definition (can't modify a non-existant thing in the first
place).
>
> or
>
> void fun(const Type& x);
This is generally sufficient.
>
> Also, is there a difference between
>
> const Type& const x
>
> and
>
> const Type const & x
>
Yes, they are both illegal in different ways. The first tries to make
something which isnt an object const and the second has two const
specifications for Type.
joe