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

Managed C++/CLI

 
AnswerRe: Convert CString array to System::String Pin
T210228-Mar-10 22:07
T210228-Mar-10 22:07 
AnswerRe: Convert CString array to System::String Pin
@Intersect☺™15-Apr-10 0:58
professional@Intersect☺™15-Apr-10 0:58 
Questioncalling a winapi function from managed code Pin
david sturzenegger15-Mar-10 6:04
david sturzenegger15-Mar-10 6:04 
AnswerRe: calling a winapi function from managed code Pin
Ghydo19-Mar-10 7:34
Ghydo19-Mar-10 7:34 
QuestionSome help needed with class and this pointer Pin
nah133712-Mar-10 13:06
nah133712-Mar-10 13:06 
AnswerRe: Some help needed with class and this pointer Pin
Garth J Lancaster12-Mar-10 15:14
professionalGarth J Lancaster12-Mar-10 15:14 
GeneralRe: Some help needed with class and this pointer Pin
nah133712-Mar-10 20:57
nah133712-Mar-10 20:57 
GeneralRe: Some help needed with class and this pointer Pin
Richard MacCutchan12-Mar-10 22:21
mveRichard MacCutchan12-Mar-10 22:21 
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 

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.