title: Can't access protected member in base class from derived class
body: <p>Heres my code :</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;sstream&gt;
  using namespace std;
  
  class root
  {
      protected :
  
              int size;
              double *array;
  
      public :
  
          virtual ~root() {}
          virtual root* add(const root&amp;) = 0;
          virtual root* sub(const root&amp;) = 0;
          virtual istream&amp; in(istream&amp;, root&amp;) = 0;
          virtual int getSize() const = 0;
          virtual void setSize(int);
  };
  
  class aa: public root
  {
  
      public :
  
          aa();
          aa(int);
          aa(const aa&amp;);
          root* add(const root&amp; a);
          root* sub(const root&amp; a);
          istream&amp; in(istream&amp;, root&amp;){}
          int getSize() const;
          void setSize(int);
  };
  
  class bb: public root
  {
  public:
      bb() { }
      bb(const bb&amp; b) { }
      root* add(const root&amp; a);
      root* sub(const root&amp; a);
      istream&amp; in(istream&amp;, root&amp;){}
      int getSize() const{}
      void setSize(int){}
  };
  
  aa::aa()
  {
      size = 0;
      array = NULL;
  }
  
  aa::aa(int nsize)
  {
      size = nsize;
      array = new double[size+1];
      for(int i=0; i&lt;size; i++)
          array[i] = 0;
  }
  
  root* aa::add(const root&amp; a)
  {
      for (int i=0; i&lt;a.size; i++)
          array[i] += a.array[i];
      return *this;
  }
  
  root* aa::sub(const root&amp; a)
  {
  }
  
  int aa::getSize() const
  {
      return size;
  }
  
  void aa::setSize(int nsize)
  {
      size = nsize;
      array = new double[size+1];
      for(int i=0; i&lt;size; i++)
          array[i] = 0;
  }
  
  root* bb::add(const root&amp; a)
  {
      return new bb();
  }
  
  root* bb::sub(const root&amp; a)
  {
  
  }
  
  int main(int argc, char **argv)
  {
  }
  </code></pre>
  
  <p>When I want to access <code>size</code> or an <code>array</code> in derived class, I just cant because my compiler says:</p>
  
  <pre><code>/home/brian/Desktop/Temp/Untitled2.cpp||In member function ‘virtual root* aa::add(const root&amp;)’:|
  /home/brian/Desktop/Temp/Untitled2.cpp|10|error: ‘int root::size’ is protected|
  /home/brian/Desktop/Temp/Untitled2.cpp|66|error: within this context|
  /home/brian/Desktop/Temp/Untitled2.cpp|11|error: ‘double* root::array’ is protected|
  /home/brian/Desktop/Temp/Untitled2.cpp|67|error: within this context|
  /home/brian/Desktop/Temp/Untitled2.cpp|68|error: cannot convert ‘aa’ to ‘root*’ in return|
  ||=== Build finished: 5 errors, 0 warnings ===|
  </code></pre>
  
  <p>I read that protected members are private in derived classes, so it seems to be ok, but it isnt. How to fix this?</p>