title: error: passing ‘const ...'’ as ‘this’ argument of ‘...’ discards qualifiers
body: <p>stockListType.cpp:58:   instantiated from here</p>
  
  <pre><code>/usr/include/c++/4.2.1/bits/stl_algo.h:91: error: passing ‘const stockType’ as ‘this’ argument of ‘bool stockType::operator&lt;(const stockType&amp;)’ discards qualifiers
  /usr/include/c++/4.2.1/bits/stl_algo.h:92: error: passing ‘const stockType’ as ‘this’ argument of ‘bool stockType::operator&lt;(const stockType&amp;)’ discards qualifiers
  /usr/include/c++/4.2.1/bits/stl_algo.h:94: error: passing ‘const stockType’ as ‘this’ argument of ‘bool stockType::operator&lt;(const stockType&amp;)’ discards qualifiers
  /usr/include/c++/4.2.1/bits/stl_algo.h:98: error: passing ‘const stockType’ as ‘this’ argument of ‘bool stockType::operator&lt;(const stockType&amp;)’ discards qualifiers
  /usr/include/c++/4.2.1/bits/stl_algo.h:100: error: passing ‘const stockType’ as ‘this’ argument of ‘bool stockType::operator&lt;(const stockType&amp;)’ discards qualifiers
  </code></pre>
  
  <p>Above is the error I got and would like someone to explain to me what it means. I solved the error by placing a constant in front of the overloading operator. My program was a stock market application that read a file that includes a string, 5 doubles and an int. We sort out the program by the string symbols and the index gain. The book instructed me to use vectors to store each data. As you see below the overload operator compares each symbol and sorts it out using the sort member function of containers. My question is why did I have to put a constant in front of the overload operator for > and &lt;. but not for >=, &lt;=, ==, != overload operators. </p>
  
  <pre><code>//function was declared in stockType.h and implemented in stockType.cpp
  bool operator&lt;(const stockType&amp; stock)//symbol is a string 
  {
    return (symbols &lt; stock.symbols)
  }
  
  
   //The function below was defined in stockListType.h and implemented in 
   //   stockListType.cpp where I instantiated the object of stockType as a vector.
     //vector&lt;stockType&gt; list; was defined in stockListType.h file
  
     void insert(const&amp; stockType item)
     {
        list.push_back(item);
        }
    void stockListType::sortStockSymbols()
      {
       sort(list.begin(), list.end());
       }
  </code></pre>