C ++ / CLI显式执行接口覆盖的(c++/cli Explicit implementatio

2019-09-19 16:31发布

我有两个接口:

public interface I1
{
    A MyProperty { get; set; }
}

public interface I2 : I1
{
    new B MyProperty { get; set; }
}

在C#中,我可以明确地实现这样的:

public class C : I1, I2
{
    public B MyProperty { get; set; }
    A I1.MyProperty { get; set; }
}

不知怎的,我有一个C ++ / CLI项目中使用这些接口。 那么,怎样才能在我C ++ / CLI实现这一点?

提前致谢。

Answer 1:

我解决了它自己。 它应该是:

public ref class C : I1, I2
{
public:
    virtual property B^ MyProperty
    {
        B^ get() { ... }
        void set(B^ value) { ... }
    }

 protected:
     virtual property A^ DummyProperty
     {
         A^ get() = I1::MyProperty::get { return nullptr; }
         void set(A^ value) = I1::MyProperty::set { }
     }
 }


文章来源: c++/cli Explicit implementation of interface overrides
标签: c++-cli