title: Force external function to be const
body: <p>Here is my problem. I made a class with a member function declared as <code>const</code> that uses an external function that I cannot modify (declared in someone else's code) and that is not declared <code>const</code>. More precisely</p>
  
  <h3>Someone else's code</h3>
  
  <pre class="lang-cpp prettyprint-override"><code>class B {
  public:
      void foo();
  };
  </code></pre>
  
  <h3>My code</h3>
  
  <pre class="lang-cpp prettyprint-override"><code>class A : public B {
  public:
      void bar() const {
          this-&gt;foo();
      }
  };
  </code></pre>
  
  <p>I know that for member data we can force const-correctness by using <code>mutable</code> or <code>const_cast</code>. How can I 'hack' <code>foo</code> such that my compiler understands that I would like to use it as if it was const even if it is not declared in someone else's code ?</p>