Will McQueen wrote:
> Hi,
>
> I'm looking at this code, and I have a quesiton about this statement:
>
>
> const SomeClass & crSomeThing = (bIsValid) ? SomeClassObjA :
> SomeClassObjB;
>
> Assignment requires an lvalue, no? Where is the lvalue? I see the
> modifier (const), the type (SomeClass), and then I expect to see a
> variable name but instead I see an address-of operator (&). How is
> "&crSomeThing" a valid variable name in this variable declaration
> statement?
>
> Thanks, Will

The variable name is "crSomeThing".
It is a 'constant reference' variable.

You could read following as:
"const SomeClass & crSomeThing" - Constant SomeClass Reference variable
crSomething

I'm sure Scott Meyers describes advantages of const references in one of his
two Effective C++ books, I spent a few minutes to hunt it down for you, but
unable to locate the exact pages.

Cheers
- Ananth


[Non-text portions of this message have been removed]

Reply via email to