title: How to make two functions with same names in Base class?
body: <p>This code compiled.</p>
  
  <pre><code>struct A
  {
      const int *getX() const
          {
              return &amp;x;
          }
  
      int *getX()
          {
              const A *thisConst = this;
              return const_cast&lt;int *&gt;(thisConst-&gt;getX());
          }
  
  
      void f()
          {
              int *p = getX();
          }
  
      int x;
  };
  </code></pre>
  
  <p>But this code didn't.</p>
  
  <pre><code>struct I
  {
      virtual const int *getX() const = 0;
  
      int *getX()
          {
              const I *thisConst = this;
              return const_cast&lt;int *&gt;(thisConst-&gt;getX());
          }
  };
  
  struct A : I
  {
      virtual const int *getX() const
          {
              return &amp;x;
          }
  
      void f()
          {
              int *p = getX();
          }
  
      int x;
  };
  </code></pre>
  
  <p>'const_cast' : cannot convert from 'const int *' to 'int *'</p>
  
  <p>I know that if I will give different names it will be compiled. But are there ways without functions renaming? </p>