title: Overriding inherited generic method in managed C++/CLI
body: <p>I wrote the code in C# and it works fine:</p>
  
  <pre><code>public interface IBase&lt;T&gt;
  {
  }
  
  public abstract class BaseImpl&lt;T&gt; : IBase&lt;T&gt; 
  {
      public abstract T2 CreateInstance&lt;T2&gt;();
  }
  
  public class InstanceX : BaseImpl&lt;string&gt;
  {
      public override T2 CreateInstance&lt;T2&gt;() 
      {
          return default(T2); 
      }
  }
  
  public class TestInstanceX
  {
      void TestIt() 
      {
          InstanceX mProvX = new InstanceX();
          string str1 = mProvX.CreateInstance&lt;String&gt;();
      }
  }
  </code></pre>
  
  <p>I have tried to move it to managed c++:</p>
  
  <pre><code>generic &lt;typename T&gt;
  public ref class BaseImpl abstract: IBase&lt;T&gt; 
  {
  public:
  
      generic &lt;typename T2&gt;
      virtual T2 CreateInstance() abstract;
  
  };
  
  public ref class InstanceX : BaseImpl&lt;String^&gt;
  {
  public:
      generic &lt;typename T2&gt;
      virtual T2 CreateInstance() override
      {
          return (T2)(Object^) nullptr; 
      }
  };
  
  public ref class TestInstanceX
  {
      void TestIt() 
      {
          InstanceX^ mProvX = gcnew InstanceX();
          String^ str1 = mProvX-&gt;CreateInstance&lt;String^&gt;();
      }
  };
  </code></pre>
  
  <p>In managed C++ I get the compiler error:</p>
  
  <blockquote>
    <p>Test.h: error C229: 'InstanceX' : cannot instantiate abstract class
             due to following members:
             'T2 BaseImpl::CreateInstance(void)' : is abstract
             with
             [
                 T=System::String ^
             ]</p>
    
    <p>Test.h: see declaration of 'BaseImpl::CreateInstance'
             with
             [
                 T=System::String ^
             ]</p>
  </blockquote>
  
  <p>How must be overridden (implemented) the "CreateInstance" function in the InstanceX class in managed C++?</p>