gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:32:53 26 4
gpt4 key购买 nike

我有一个 .NET_4 Managed C++ ref 类,它派生自用 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' : matches base ref class method 'Core::ResourceManager::_Resource::Delete', but is not marked 'new' or 'override'; 'new' (and 'virtual') is assumed

从 C# 类覆盖 virtual 函数的正确托管 C++ 语法是什么?

最佳答案

你把 override after the function signature .

//MANAGED C++ CLASS
namspace Input.DI
{
public ref class Mouse : ResourceManager::_Resource
{
public:
virtual void Delete() override {}
};
}

关于c# - "C# base class virtual function"- "override in Managed C++ ref class",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3783861/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com