我有一个.NET_4托管C ++引用类,它派生自用C#编写的.NET_4基类。
C#基类:
namespace Core
{
public class ResourceManager
{
public class _Resource
{
public virtual void Delete() {}
}
}
}
托管C ++类:
namespace Input.DI
{
public ref class Mouse : ResourceManager::_Resource
{
public:
virtual void Delete() {}
};
}
这是我得到的错误:
'Input :: DI :: Mouse :: Delete':匹配base ref class方法'Core :: ResourceManager :: _ Resource :: Delete',但未标记为'new'或'override';假设'new'(和'virtual')
从C#类覆盖virtual
函数的正确托管C ++语法是什么?
答案 0 :(得分:6)
你放override
after the function signature。
//MANAGED C++ CLASS
namspace Input.DI
{
public ref class Mouse : ResourceManager::_Resource
{
public:
virtual void Delete() override {}
};
}