Re: How to eliminate assignment operator generation warning



Tron Thomas wrote:
> What is the reason the reference variable m_value cannot be copied?
> As far as I know there should be no problem with this. It is
> perfectly legal to do the following:

References cannot be copied. Ever.

>
> int value = 42;
> int& first = value
> int& second = first; // copy of the first reference

Not really a copy of the first reference, but a new reference to 'value'.

Here's the case that matters though:

int value;
int& first = value;
int other;
int& second = other;

// legal, but doesn't assign the reference
// instead, 'other' is set to the same value as 'value'.
second = first;

-cd


.



Relevant Pages