Can't access protected member variables of the most base class through std::unique_ptr in diamond
问题 I am not an advanced programmer. Suppose there is a classic diamond inheritance: class Base class A: virtual public Base class B: virtual public Base class Last: public A, public B Suppose Base has a variable, m_x , that is common to both A and B , such that only one of A , or B , can be called at a time, not both (which is what is needed). To get around this, this is used: class Last: public A, public B { private: std::unique_ptr<Base> m_p; public: Last(int i) { if (i) m_p = std::unique_ptr