473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C++/CLI: Explicit interface property implementation

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
Jul 29 '08 #1
4 5777
On Jul 29, 6:27*pm, innes <inn...@gmail.comwrote:
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 :-)
Jul 29 '08 #2
"innes" <in****@gmail.comwrote in message
news:8f**********************************@m44g2000 hsc.googlegroups.com...
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

--
Mark Salsbery
Microsoft MVP - Visual C++

>
Thanks,
Innes
Jul 29 '08 #3
// All the implementations of the interface need to be public and
marked virtual...
That's *implicit* implementation.
>
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

>>
Thanks,
Innes

Jul 29 '08 #4
"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:#M**************@TK2MSFTNGP02.phx.gbl...
>// All the implementations of the interface need to be public and
marked virtual...

That's *implicit* implementation.

I had to look that up LOL Thanks! Learn something new every day!

Cheers,
Mark

--
Mark Salsbery
Microsoft MVP - Visual C++

Jul 30 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ioannis Vranos | last post by:
I have initiated a similar discussion thread in clc++m, however because of the "m" in the name, the discussion is progressing slowly, so I am setting another thread here. Well the story is...
12
by: Steve W. | last post by:
I just read the section (and did the exercise) in the C# Step by Step book that covers Explict Interface Implementation (where you specify in the method implementation the specific interface that...
10
by: Martin Zenkel | last post by:
Assumed two assemblies (one C# and one C++), C++ refers to C#. The follwing code compiles and works well under VS 2002! VS 2003 C++ compiler reports the error "error 2555:...
7
by: Ioannis Vranos | last post by:
Fellows there is probably a serious implementation bug of C++/CLI indexed property in VC++ 2005, it looks like it is implemented the opposite way than the C++/CLI draft says! At first the...
1
by: Grafix | last post by:
All - I am facing couple of problems with events in CLI C++. If i have an interface that declares few events, and a ref class implements that interface, should it do anything extra from events...
1
by: midnight madness | last post by:
I tried but failed to implement a template class that support IEnumerator<T> interface using C++/CLI in VS 2005 Professional version. I could not figure out the proper syntax to implement the...
0
by: Brandon Driesen | last post by:
The following illustrates my question. Why is it when I bind to an a collection of items whose interface implementation is explicit, there is an error during the binding process wherein the error...
1
by: =?Utf-8?B?Sk0=?= | last post by:
In an application I have an interface with methods and properties. The interface is used on a Class (ie class MyClass : IMyClassA, IMyClassB). On a windows form I define a BindingSource...
12
by: Howard Swope | last post by:
This problem has been bugging me for a while. I have created a collection class and implemented it in a C# library. If I inherit from this class in another C# assembly and it works, but if I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.