<- Chameleon -> wrote:[color=blue]
> what is the meaning of 2 *const* in following line?
> -----------
> const MyClass MyFunction const (MyClass &a);
> -----------[/color]
I suspect you mean somthing like this because what you have above is not
standard C++.
<- Chameleon -> wrote:
[color=blue]
> what is the meaning of 2 *const* in following line?
> -----------
> const MyClass MyFunction const (MyClass &a);
> -----------[/color]
Is that legal code? If it were
const MyClass* MyFunction( MyClass &a ) const;
the last const would mean that MyFunction can't change any of the fields
(member variables) of MyClass, and the first const would mean that
MyFunction returns a constant pointer to a MyClass object -- that is,
the returned pointer cannot be used to change what it points to.
"Martin Magnusson" <loveslave@frus tratedhousewive s.zzn.com> wrote in message news:bkt109$qe5 $1@green.tninet .se...[color=blue]
> <- Chameleon -> wrote:
>[color=green]
> > what is the meaning of 2 *const* in following line?
> > -----------
> > const MyClass MyFunction const (MyClass &a);
> > -----------[/color]
>
> Is that legal code? If it were
>[/color]
No. The last const after the function name is not allowed.
The first const is OK, but sort of spurious since the return
value usually gets copied anyhow, it will lose the constness.
Comment