title: How to discard const in c++
body: <p>This is what I'm trying to do and I can't:</p>
  
  <pre><code>#include &lt;string&gt;
  using namespace std;
  class A {
  public:
    bool has() const { return get().length(); }
    string&amp; get() { /* huge code here */ return s; }
  private:
    string s;
  };
  </code></pre>
  
  <p>The error I'm getting is:</p>
  
  <pre><code>passing ‘const A’ as ‘this’ argument of
  ‘std::string&amp; A::get()’ discards qualifiers
  </code></pre>
  
  <p>I understand what the problem is, but how can I fix it? I really need <code>has()</code> to be <code>const</code>. Thanks.</p>