title: C++ Access private member from a derived class to another derived class (both have the same base class)
body: <p>So I have a base class with two derived classes (deriv1 and deriv2).
  On the deriv2 class I need to access a private member from deriv1...
  How can I do this?</p>
  
  <p>Sample code:</p>
  
  <pre><code>    class base
      {
      private:
  
      public:
          base() {};
          ~base() {};
      };
  
      class deriv1 : public base
      {
      private:
          int m_member1;
      public:
          deriv1() {};
  
          ~deriv1() {};
      };
  
      class deriv2 : public base
      {
      private:
          int m_member2;
      public:
          deriv2() {};
  
          ~deriv2() {};
      int sum_members_because_yes(void)
      {
          return (deriv1::m_member1 + m_member2); // &lt;---- :((
      }
  };
  </code></pre>
  
  <p><strong>How can I access a private member from another derived class?</strong>
  I was trying to avoid using friend functions, or changing the private member to public... <strong>What do you advice?</strong></p>
  
  <p>Thank you! :)</p>