title: While using Inheritance property, the derived class does not take the data members of the template base class. Why is that and how can it be solved?
body: <p>The base class here is Rectangle and it is a template class. I have derived a class called ColorRectangle from Rectangle and it is also a template class. But ColorRectangle cannot access the protected data members of Rectangle. How can I solve this?  </p>
  
  <p>Rectangle header file</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  template &lt;class T&gt;
  class Rectangle{
  protected:
      T length;
      T breadth;
  public:
      void setLength(T len){
          length = len;
      }
      void setBreadth(T bre){
          breadth = bre;
      }
  
      T getLength(){
          return length;
      }
      T getBreadth(){
          return breadth;
      }
      T area(){
          return length*breadth;
      }
  };
  </code></pre>
  
  <p>ColorRectangle Header file</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include"Rectangle.h"
  using namespace std;
  
  template &lt;class T&gt;
  class ColorRectangle:public Rectangle&lt;T&gt;{
    private:
      T borderWidth;
      string borderColor;
  
    public:
      void setBwidth(T bw){
          borderWidth = bw;
      }
      void setColor(string bc){
          borderColor = bc;
      }
      T calcPerimeter(){
          return 2 * (length + breadth);  
      }
  };
  </code></pre>