title: c++ inheritance - same method name with different argument type
body: <p>I'm trying to compile following code in VC++ 2010:</p>
  
  <pre><code>class Base
  {
  public:
      std::wstring GetString(unsigned id) const
      {
          return L"base";
      }
  };
  
  class Derived : public Base
  {
  public:
      std::wstring GetString(const std::wstring&amp; id) const
      {
          return L"derived";
      }
  };
  
  int wmain(int argc, wchar_t* argv[])
  {
      Derived d;
  
      d.GetString(1);
  }
  </code></pre>
  
  <p>My understanding was that Derived will have two methods:</p>
  
  <pre><code>std::wstring GetString(unsigned id) const
  std::wstring GetString(const std::wstring&amp; id) const
  </code></pre>
  
  <p>so my code should compile succesfully. Visual C++ 2010 however reports following error:</p>
  
  <pre><code>test.cpp(32): error C2664: 'Derived::GetString' : cannot convert parameter 1 from 'int' to 'const std::wstring &amp;'
        Reason: cannot convert from 'int' to 'const std::wstring'
        No constructor could take the source type, or constructor overload resolution was ambiguous
  </code></pre>
  
  <p>What am I doing wrong? The code works perfectly when I use it this way:</p>
  
  <pre><code>Derived d;
  Base base = d;
  base.GetString(1);
  </code></pre>
  
  <p>or when both variants of GetString are defined in same class.</p>
  
  <p>Any ideas? I would like to avoid explicit typecasting.</p>