I'm trying to use a C++/CLI auto-implemented property to explicitly override an interface. In particular, I have written (in C++/CLI)
interface IInterface
{
property Object ^MyProperty
{
Object ^get(void);
void set(Object^);
}
void Method(void);
}
To explicitly consume IInterface
in C#, one would write
class MyClass : IInterface
{
Object IInterface.MyProperty { get; set;}
void IInterface.Method()
{
}
}
C++/CLI does not support EII, but it does support explicit overrides. For example, one can write
sealed ref class MyClass : IInterface
{
private:
virtual void method(void) = IInterface::Method {}
public:
property Object ^MyProperty;
}
I want to define my explicit override using an auto-implemented property, but
sealed ref class MyClass : IInterface
{
private:
virtual void method(void) = IInterface::Method {}
property Object ^myProperty = IInterface::MyProperty;
}
yields the compiler errors C2146
: Missing ;
before identifier Object
, C2433
: virtual
not permitted on data declarations, C4430
: Missing type specifier, and C3766
: Interface member not implemented. Am I missing something? What is the appropriate C++/CLI syntax to achieve what I seek?