Click here to Skip to main content
15,900,258 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: C++/CLI operators in ref classes and interface classes Pin
Nish Nishant28-Feb-10 8:22
sitebuilderNish Nishant28-Feb-10 8:22 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
Edward Diener28-Feb-10 9:50
Edward Diener28-Feb-10 9:50 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
Nish Nishant28-Feb-10 12:28
sitebuilderNish Nishant28-Feb-10 12:28 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
Edward Diener28-Feb-10 14:24
Edward Diener28-Feb-10 14:24 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
Nish Nishant28-Feb-10 16:23
sitebuilderNish Nishant28-Feb-10 16:23 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
N a v a n e e t h1-Mar-10 23:18
N a v a n e e t h1-Mar-10 23:18 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
N a v a n e e t h1-Mar-10 23:19
N a v a n e e t h1-Mar-10 23:19 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
Edward Diener2-Mar-10 2:31
Edward Diener2-Mar-10 2:31 
In order to code operators for an interface.

In dotNet all operators must be static methods in order to be CLS compliant.

There is no reason interfaces should not have operators just like classes do. If I have some functionality written in terms of interfaces, why should I not be allowed to use operators, where appropriate, instead of member functions ? Here is a simple, trivial example in C++/CLI:

interface class MultiplyTwoIntegers
{
int Multiply(int);
static int operator * (MultiplyTwoIntegers ^ first, MultiplyTwoIntegers ^ second) { return(first -> Multiply(second));
};

ref class MyInteger : MultiplyTwoIntegers
{
// Some functionality...
int Multiply(int other)
{
// ... some functionality return an int
}
}

int DoTheMultiplyAmongOtherThings(MultiplyTwoIntegers ^ one, MultiplyTwoIntegers ^ two)
{
int result(one * two);
// Some processing ...
return result;
}

// Somewhere else we have this code

MyInteger ^ my1(gcnew MyInteger);
MyInteger ^ my2(gcnew MyInteger);
int result(DoTheMultiplyAmongOtherThings(my1,my2));

As I said this is a trivial example but in real world programming much functionality can be created based on interfaces being passed to functionality and operating on those interfaces. Allowing operators for interfaces makes the syntax much nicer than if they are not allowed. This should be no different from classes. In C++/CLI one can code the above without error, since interface operators are allowed. In C# interface operators are not allowed, nor are any static functions, properties, or events for an interface.
Edward Diener

GeneralRe: C++/CLI operators in ref classes and interface classes Pin
N a v a n e e t h2-Mar-10 5:06
N a v a n e e t h2-Mar-10 5:06 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
Edward Diener2-Mar-10 5:44
Edward Diener2-Mar-10 5:44 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
N a v a n e e t h2-Mar-10 6:57
N a v a n e e t h2-Mar-10 6:57 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
Edward Diener2-Mar-10 8:51
Edward Diener2-Mar-10 8:51 
QuestionRetrieving a control's information Pin
Jayapal Chandran23-Feb-10 23:29
Jayapal Chandran23-Feb-10 23:29 
AnswerRe: Retrieving a control's information Pin
Richard MacCutchan24-Feb-10 1:37
mveRichard MacCutchan24-Feb-10 1:37 
GeneralRe: Retrieving a control's information Pin
Ron Aldrich4-Mar-10 10:08
Ron Aldrich4-Mar-10 10:08 
GeneralRe: Retrieving a control's information Pin
Richard MacCutchan4-Mar-10 21:13
mveRichard MacCutchan4-Mar-10 21:13 
QuestionManaged Extensions in VS2008 ? Pin
gvanto23-Feb-10 12:23
gvanto23-Feb-10 12:23 
AnswerRe: Managed Extensions in VS2008 ? Pin
Richard Andrew x6423-Feb-10 14:51
professionalRichard Andrew x6423-Feb-10 14:51 
GeneralRe: Managed Extensions in VS2008 ? Pin
gvanto23-Feb-10 18:50
gvanto23-Feb-10 18:50 
GeneralRe: Managed Extensions in VS2008 ? Pin
Richard Andrew x6424-Feb-10 2:25
professionalRichard Andrew x6424-Feb-10 2:25 
GeneralRe: Managed Extensions in VS2008 ? Pin
gvanto24-Feb-10 13:54
gvanto24-Feb-10 13:54 
QuestionSending values to WPF control from VC++ Pin
Anu_Bala14-Feb-10 22:00
Anu_Bala14-Feb-10 22:00 
Questionusing microsoft enterprise library in .net dll to be called from COM application Pin
chana gibber10-Feb-10 5:02
chana gibber10-Feb-10 5:02 
AnswerRe: using microsoft enterprise library in .net dll to be called from COM application Pin
N a v a n e e t h10-Feb-10 5:18
N a v a n e e t h10-Feb-10 5:18 
GeneralRe: using microsoft enterprise library in .net dll to be called from COM application Pin
chana gibber10-Feb-10 5:22
chana gibber10-Feb-10 5:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.