Re: 'const' usage
* lost_in_space:
"Vladimir Grigoriev" <vlad.moscow@mail.ru> wrote in message
news:efyMr2muIHA.2292@TK2MSFTNGP05.phx.gbl...
"Giovanni Dicanio" <giovanni.dicanio@invalid.com> wrote in message
news:eAhXknbuIHA.5580@TK2MSFTNGP04.phx.gbl...
It is not weired.
In fact, you can have a const method that returns a non-const object,
e.g.
SomeObject * SomeFactory::BuildSomeObject() const
{
...
return new SomeObject(...);
}
The caller can modify SomeObject instance (returned by pointer); but the
BuildSomeObject method (of class SomeFactory) does not modify the
internal status of SomeFactory instance.
It is more weired if three const qualifiers are present. :)
const SomeObject * const SomeFactory::BuildSomeObject() const;
>
> I understand what the first and third are doing; what effect does the second
> have?
None, because rvalues of built-in types are effectively const already.
Cheers, & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?