相关疑难解决方法(0)

从C++/CLI实现在C#中声明的接口

假设我有一个名为C#的接口IMyInterface定义如下:

// C# code
public interface IMyInterface
{
  void Foo(string value);
  string MyProperty { get; }
}
Run Code Online (Sandbox Code Playgroud)

假设我还有一个C++/CLI类MyConcreteClass,它实现了这个接口,其头部声明如下:

// C++/CLI header file
ref class MyConcreteClass : IMyInterface
{
public:

};
Run Code Online (Sandbox Code Playgroud)

如何在C++/CLI头中实现方法Foo和属性MyProperty

我的尝试导致以下编译错误:

错误C3766:'MyConcreteClass'必须为接口方法提供一个实现'void IMyInterface :: Foo(System :: String ^ value)'

c++-cli

34
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++-cli ×1