Boost logo

Boost Users :

From: Max (LoadCom_at_[hidden])
Date: 2008-05-19 22:14:29


>> Thank you for your clarification.
>>
>> I just didn't know the fact that ref type member var's could
>> be assigned using '=' before you told me.
>
>It sounds like you'd be assigning the underlying variable the references
>were initialized with, but you want is to make the reference point at a
>different variable?

Your are right and it's my fault. I should have had a trial-and-test
before posting a reply. :-(

To make it clearer, I'm finding something like this:
class Foo
{
        int & i_;
        Foo& operator=(const Foo& rhs)
        {
                if(&rhs == this) return *this;
                i_ = rhs.i_;
                return *this;
        }
}

this is not accepted by my VC9 compiler.

>
>>
>> However, I'm also curious on the question you raised for me: :-)
>>
>> Is it possible to make a class which has reference type members
>> default constructible?
>>
>> AFAIK, the answer is no. I hope and don't hope there's a different
>> answer.
>
>It sounds like you need to be using pointers instead of references.

Yes, it seems to be the only way, as far as I don't to make thing more
complex by using another layer of indirectness.

Thanks for your time

B/Rgds
Max


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net