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

Managed C++/CLI

 
QuestionManaged c++ std::string not accessible in unmanaged c++ Pin
Radh-e-sham11-Mar-10 20:42
Radh-e-sham11-Mar-10 20:42 
AnswerRe: Managed c++ std::string not accessible in unmanaged c++ Pin
KarstenK11-Mar-10 21:46
mveKarstenK11-Mar-10 21:46 
AnswerRe: Managed c++ std::string not accessible in unmanaged c++ Pin
T210228-Mar-10 22:10
T210228-Mar-10 22:10 
Questionsse 2-D Inner product and transpose Pin
SMART LUBOBYA4-Mar-10 4:24
SMART LUBOBYA4-Mar-10 4:24 
QuestionIs it possible to implement a DataSource in a mixed-mode DLL? Pin
Ron Aldrich3-Mar-10 22:38
Ron Aldrich3-Mar-10 22:38 
AnswerRe: Is it possible to implement a DataSource in a mixed-mode DLL? Pin
N a v a n e e t h4-Mar-10 4:24
N a v a n e e t h4-Mar-10 4:24 
GeneralRe: Is it possible to implement a DataSource in a mixed-mode DLL? Pin
Ron Aldrich4-Mar-10 9:53
Ron Aldrich4-Mar-10 9:53 
QuestionInterface operator bug or feature with implicit/explicit cast ? Pin
Edward Diener3-Mar-10 2:43
Edward Diener3-Mar-10 2:43 
An interface in C++/CLI can have operators as static functions of the interface. If I code an implicit cast operator for an interface the compiler accepts it:

// VC9ClrConsoleApplication.cpp : main project file.

#include "stdafx.h"

using namespace System;

interface class AnInterface
{

static operator int (AnInterface ^ af) { return af -> IntReturn(); }

int IntReturn();

};

int main(array<System::String ^> ^args)
{

Console::WriteLine(L"Hello World");
Console::ReadKey();
return 0;
}

This compiles with no errors.
If I change my operator from an implicit cast to an explicit cast I get a C2071 illegal storage class error:

// VC9ClrConsoleApplication.cpp : main project file.

#include "stdafx.h"

using namespace System;

interface class AnInterface
{

static explicit operator int (AnInterface ^ af) { return af -> IntReturn(); }

int IntReturn();

};

int main(array<System::String ^> ^args)
{

Console::WriteLine(L"Hello World");
Console::ReadKey();
return 0;
}

".\VC9ClrConsoleApplication.cpp(10) : error C2071: 'AnInterface::operator int' : illegal storage class".

I can so no reason why an implicit cast operator is allowed for an interface and an explcit cast operator is not allowed for an interface.

For an implicit cast operator one would be able to say:

AnInterface ^ ai = CreationFunctionFromClassImplementingInterface();
int i = ai;

For an explicit cast operator, if it worked with interfaces, one would be able to say:

AnInterface ^ ai = CreationFunctionFromClassImplementingInterface();
int i = static_cast<int>(ai);

Is this a bug or is it, for some reason I can not fathom, just the way C++/CLI is supposed to work.
Edward Diener

AnswerRe: Interface operator bug or feature with implicit/explicit cast ? Pin
Nish Nishant10-Mar-10 2:58
sitebuilderNish Nishant10-Mar-10 2:58 
GeneralRe: Interface operator bug or feature with implicit/explicit cast ? Pin
Edward Diener10-Mar-10 4:13
Edward Diener10-Mar-10 4:13 
QuestionBACKGROUNDWORKER in vc++ clr net 2.0 need example Pin
ajaxswan1-Mar-10 23:15
ajaxswan1-Mar-10 23:15 
AnswerRe: BACKGROUNDWORKER in vc++ clr net 2.0 need example Pin
N a v a n e e t h1-Mar-10 23:27
N a v a n e e t h1-Mar-10 23:27 
QuestionDll Pin
MsmVc25-Feb-10 20:04
MsmVc25-Feb-10 20:04 
AnswerRe: Dll Pin
Richard MacCutchan25-Feb-10 22:14
mveRichard MacCutchan25-Feb-10 22:14 
GeneralRe: Dll Pin
MsmVc25-Feb-10 22:20
MsmVc25-Feb-10 22:20 
GeneralRe: Dll Pin
Richard MacCutchan25-Feb-10 22:59
mveRichard MacCutchan25-Feb-10 22:59 
GeneralRe: Dll Pin
MsmVc25-Feb-10 23:09
MsmVc25-Feb-10 23:09 
GeneralRe: Dll Pin
Richard MacCutchan26-Feb-10 0:08
mveRichard MacCutchan26-Feb-10 0:08 
QuestionCannot inspect... Assuming significant changes. Please help! Pin
Xpnctoc25-Feb-10 13:48
Xpnctoc25-Feb-10 13:48 
AnswerRe: Cannot inspect... Assuming significant changes. Please help! Pin
Xpnctoc26-Feb-10 3:10
Xpnctoc26-Feb-10 3:10 
GeneralRe: Cannot inspect... Assuming significant changes. Please help! Pin
Xpnctoc26-Feb-10 3:47
Xpnctoc26-Feb-10 3:47 
QuestionC++/CLI operators in ref classes and interface classes Pin
Edward Diener24-Feb-10 14:33
Edward Diener24-Feb-10 14:33 
AnswerRe: C++/CLI operators in ref classes and interface classes Pin
Richard Andrew x6425-Feb-10 14:43
professionalRichard Andrew x6425-Feb-10 14:43 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
Edward Diener26-Feb-10 2:03
Edward Diener26-Feb-10 2:03 
GeneralRe: C++/CLI operators in ref classes and interface classes Pin
Richard Andrew x6426-Feb-10 3:50
professionalRichard Andrew x6426-Feb-10 3:50 

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.