Compiler error for modifying a non-const object
<pre><code> #include "iostream"
 #include "vector"


 class ABC {

  private:
      bool m_b;
  public:
      ABC() : m_b(false) {}

      ABC&amp; setBool(bool b) {
          m_b = b;
          return *this;
      }

      bool getBool() const {
          return m_b;
      }
};

 void foo(const std::vector&lt;ABC&gt; &amp;vec) {

      vec[0].setBool(true);
 }

 int main(int argc, char*argv[]) {

     std::vector&lt;ABC&gt; vecI;
     ABC i;
     vecI.push_back(i);
     foo(vecI);
 }
</code></pre>

<p>When I compile it I get this error: passing <code>const ABC</code> as <code>this</code> argument of <code>ABC&amp; ABC::setBool(bool)</code> discards qualifiers</p>

<p>Any ideas why this would happen since the object itelf is not a constant.</p>
