Boost logo

Boost Users :

From: Meryl Silverburgh (silverburgh.meryl_at_[hidden])
Date: 2008-07-16 15:53:32


On Wed, Jul 16, 2008 at 12:13 PM, Igor R <boost.lists_at_[hidden]> wrote:
>> I don't need to do 'b= NULL' in A's constructor, right?
>
> Right.
>
>> But why this line won't compile "b = new B();" ?
>
> The constructor you need for this conversion is declared as
> "explicit". Do it this way:
>
> typedef boost::shared_ptr<B> BPtr;
> B& A::getB() {
> if (!b)
> b = BPtr(new B());
> return *b; // btw, do you really wish to return the reference?
> }

Thank you. You said 'btw, do you really wish to return the reference?'
, Can you please tell me what do you mean, like what kind of problems
it will cause?

> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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