class B;
typedef boost::shared_ptr<BBPtr;
class A
{
public:
explicit A(BPtr b) : _b1(b) {}
A(BPtr b1, BPtr b2) : _b1(b1), _b2(b2) {}
void f() {
if (_b1) {
// do some stuff with _b1
}
if (_b2) {
// do some stuff with _b2
}
}
private:
BPtr _b1;
BPtr _b2;
};
I'd like to construct an object A using the second c-tor but with _b1
and _b2 sharing the same object. To achieve that, I write
BPtr b(new B);
A a(b, b);
Now, I'd like to do the initialization from a derived class D.
class D
{
public:
D() : A(?, ?) {}
};
Is there a way to achieve this without modifying the semantic of the
base class A ?
Thank you.