Can a class member of type boost::scoped_ptr
be initialized inside the class' constructor? How?
(Not in the initialization list)
Yes. you can use reset() member function.
class foo {
public:
foo()
{
p.reset(new bar());
}
private:
boost::scoped_ptr<bar> p;
};
scoped_ptr has a method scoped_ptr<T>::reset(T * p=0)
which you can call in your enclosing class's constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With