title: compiler "error: passing ‘const something’ as ‘this’ argument discards qualifiers"
body: <p>I am making a custom list using templates in C++ and get some compilation error.<br>
  The code is very large in length , so here is a small snippet of the code from where the error is coming. Compilation error is given below. You can compile it your own system to see the same error.  </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  template &lt;class T&gt;
  class sortedList
  {
      int m_count;
      public:
      sortedList(){m_count = 0;}
      int length(){ return m_count; }
  
  };
  
  
      void output(const sortedList&lt;int&gt;&amp; list)
      {
          cout &lt;&lt; "length" &lt;&lt; list.length() &lt;&lt; endl;
          return;
      }
  
  int main() {
      // your code goes here
  
      sortedList &lt;int&gt; list1;
      output(list1);
  
      return 0;
  }
  </code></pre>
  
  <p>I am getting compilation error : </p>
  
  <pre><code>prog.cpp: In function ‘void output(const sortedList&lt;int&gt;&amp;)’:
  prog.cpp:17:35: error: passing ‘const sortedList&lt;int&gt;’ as ‘this’ argument discards qualifiers [-fpermissive]
     cout &lt;&lt; "length" &lt;&lt; list.length() &lt;&lt; endl;
                                     ^
  prog.cpp:10:6: note:   in call to ‘int sortedList&lt;T&gt;::length() [with T = int]’
    int length(){ return m_count; }
  </code></pre>