0

There's two issues with this code:

  1. Enabling shared from this on class B which is a derived class
  2. 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?

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
Tom
  • 1,235
  • 9
  • 22

0 Answers0