title: How to call a non-const function within a const function (C++)
body: <p>I have a legacy function that looks like this:</p>
  
  <pre><code>int Random() const
  {
    return var_ ? 4 : 0;
  }
  </code></pre>
  
  <p>and I need to call a function within that legacy code so that it now looks like this:</p>
  
  <pre><code>int Random() const
  {
    return var_ ? newCall(4) : 0;
  }
  </code></pre>
  
  <p>The problem is that I'm getting this error: </p>
  
  <pre><code>In member function 'virtual int Random() const':
  class.cc:145: error: passing 'const int' as 'this' argument of 'int newCall(int)' discards qualifiers
  </code></pre>
  
  <p>Now I know in order to fix this error I can make my <code>newCall()</code> a const function. But then I have several funciton calls in <code>newCall()</code> that I have to make, so now I would have to make all of those function calls const.  And so on and so forth until eventually I feel like half my program is going to be const.  </p>
  
  <p>My question: is there any way to call a function within Random() that isn't const?  Or does anyone have any ideas on how to implement <code>newCall()</code> within <code>Random()</code> without making half my program const.  </p>
  
  <p>Thanks</p>
  
  <p>-josh</p>