0

In the code below, I understand it to mean that myBigStruct is inheriting multiple things. The obvious part is it's inheriting 2 structs (mySmallStruct and someOtherStruct).

But I am not sure what it means to inherit from a shared pointer. (My understanding is that std::enabled_shared_from_this returns a shared pointer to a myBigStruct - presumably a pointer to the struct I am defining?)

Can somebody please explain?

 struct myBigStruct final
        : public mySmallStruct
        , public std::enable_shared_from_this<myBigStruct>
        , public someOtherStruct
        {
Fuad
  • 1,309
  • 1
  • 15
  • 30
  • To be clear, inheriting from `std::enable_shared_from_this` is _NOT_ "inheriting from a shared pointer". That would look like `struct myBigStruct : std::shared_ptr ...` and should not be done. Inheriting from `std::enable_shared_from_this` means inheriting the `shared_from_this()` member function in order to get a `shared_ptr` referring to `this` – alter_igel Jun 16 '21 at 21:45

0 Answers0