Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"C# base class virtual function" - "override in Managed C++ ref class"

I have a .NET_4 Managed C++ ref class that I derive from a .NET_4 base class written in C#.

C# base class:

namespace Core
{
  public class ResourceManager
  {
    public class _Resource
    {
      public virtual void Delete() {}
    }
  }
}

Managed C++ class:

namespace Input.DI
{
  public ref class Mouse : ResourceManager::_Resource
  {
    public:
    virtual void Delete() {}
  };
}

Here is the error I'm getting:

'Input::DI::Mouse::Delete' : matches base ref class method 'Core::ResourceManager::_Resource::Delete', but is not marked 'new' or 'override'; 'new' (and 'virtual') is assumed

What is the correct managed C++ syntax to override a virtual function from a C# class?

like image 876
zezba9000 Avatar asked Sep 24 '10 02:09

zezba9000


1 Answers

You put override after the function signature.

//MANAGED C++ CLASS
namspace Input.DI
{
  public ref class Mouse : ResourceManager::_Resource
  {
    public:
    virtual void Delete() override {}
  };
}
like image 147
Igor Zevaka Avatar answered Sep 20 '22 18:09

Igor Zevaka