Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-05-20 00:15:50


AMDG

Max wrote:
> 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.
>

It isn't? I don't see a problem (other than that it may not be what you
intend),
and I just compiled the above snippet with vc9.

>>> 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.
>

Well, the indirectness is still there with references. It's just hidden.

In Christ,
Steven Watanabe


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