C++/CLI: Explicit interface property implementation

  • Thread starter Thread starter innes
  • Start date Start date
I

innes

Hi,
I'm unable to work out the syntax for explicit implementation of an
interface property.

Example Code:
-----

public interface class ITest
{
int M();
property int P { int get(); }
};

public ref class C : ITest
{
protected:
virtual int M() = ITest::M
{ return 0; }

virtual property int P = ITest::P // <==============
{
int get()
{ return 0; }
}
};

-----

The line commented with an arrow is my wild guess at what the syntax
might be, but this doesn't compile.

Does anyone know the correct syntax?

Thanks,
Innes
 
Does anyone know the correct syntax?

Ahah, it's "protected: virtual int property P { int get() =
ITest::P::get {...} }"

C++/CLI:- C# made less readable :-)
 
innes said:
Hi,
I'm unable to work out the syntax for explicit implementation of an
interface property.

Example Code:
-----

public interface class ITest
{
int M();
property int P { int get(); }
};

public ref class C : ITest
{
protected:
virtual int M() = ITest::M
{ return 0; }

virtual property int P = ITest::P // <==============
{
int get()
{ return 0; }
}
};

-----

The line commented with an arrow is my wild guess at what the syntax
might be, but this doesn't compile.

Does anyone know the correct syntax?


// All the implementations of the interface need to be public and marked
virtual...

public interface class ITest
{
int M();
property int P { int get(); }
};

public ref class C : ITest
{
public:

virtual int M()
{ return 0; }

property int P
{
virtual int get()
{ return 0; }
}
};

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top