There's two issues with this code:
- Enabling shared from this on class B which is a derived class
- Calling shared_from_this() in the constructor of each class.
class A : public std::enable_shared_from_this<A> {
public:
A() {
shared_from_this();
}
};
class B : public A, public std::enable_shared_from_this<B> {
public:
B() {
shared_from_this();
}
};
Is there to allow both classes to use shared_from_this from their constructors?