Click here to Skip to main content

Managed C++/CLI

    RSS: RSS Feed

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page  Show 
  Refresh
GeneralRe: Dll PinmvpRichard MacCutchan23:59 25 Feb '10  
GeneralRe: Dll PinmemberMsmVc0:09 26 Feb '10  
GeneralRe: Dll PinmvpRichard MacCutchan1:08 26 Feb '10  
QuestionCannot inspect... Assuming significant changes. Please help! PinmemberXpnctoc14:48 25 Feb '10  
AnswerRe: Cannot inspect... Assuming significant changes. Please help! PinmemberXpnctoc4:10 26 Feb '10  
GeneralRe: Cannot inspect... Assuming significant changes. Please help! PinmemberXpnctoc4:47 26 Feb '10  
QuestionC++/CLI operators in ref classes and interface classes PinmemberEdward Diener15:33 24 Feb '10  
In C++/CLI if I add an operator to an interface class and implement that interface in a ref class, the operator is not recognized for the ref class. But if I add an operator to a base ref class and inherit from that base ref class in a derived ref class, the operator is recognized for that derived ref class:
 
#include "stdafx.h"
 
using namespace System;
 
interface class Base
  {
  
  public:
  
	static int operator * (Base ^ it) { return 3; }
  
  };
  
ref class Derived : Base
  {
  
  };
 
int main(array<System::String ^> ^args)
{
 
    Derived ^ d(gcnew Derived);
    
    int amt = *d;
 
    Console::WriteLine(L"Hello World");
    return 0;
}
 
The above compiles with an error of:
 
error C2440: 'initializing' : cannot convert from 'Derived' to 'int'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
 
But if one changes the line in the code above from 'interface class base' to 'ref class base', the code compiles and runs with no errors.
 
Does anybody know why this behavior occurs ?
Edward Diener

AnswerRe: C++/CLI operators in ref classes and interface classes PinmemberRichard Andrew x6415:43 25 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmemberEdward Diener3:03 26 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmemberRichard Andrew x644:50 26 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmemberEdward Diener6:21 26 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmemberRichard Andrew x646:26 26 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmemberEdward Diener11:44 26 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmvpNishant Sivakumar9:24 28 Feb '10  
AnswerRe: C++/CLI operators in ref classes and interface classes PinmvpNishant Sivakumar9:22 28 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmemberEdward Diener10:50 28 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmvpNishant Sivakumar13:28 28 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmemberEdward Diener15:24 28 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmvpNishant Sivakumar17:23 28 Feb '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmvpN a v a n e e t h0:18 2 Mar '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmvpN a v a n e e t h0:19 2 Mar '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmemberEdward Diener3:31 2 Mar '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmvpN a v a n e e t h6:06 2 Mar '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmemberEdward Diener6:44 2 Mar '10  
GeneralRe: C++/CLI operators in ref classes and interface classes PinmvpN a v a n e e t h7:57 2 Mar '10  

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

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


Advertise | Privacy | Mobile
Web04 | 2.5.120206.1 | Last Updated 8 Feb 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid