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

Managed C++/CLI

 
GeneralRe: Unverifiable assembly 'GIS.View' failed policy check Pin
Paul Selormey20-Feb-03 2:20
Paul Selormey20-Feb-03 2:20 
GeneralNeed help with casting __gc-pointer to void* and then back again Pin
Anonymous16-Feb-03 12:52
Anonymous16-Feb-03 12:52 
GeneralRe: Need help with casting __gc-pointer to void* and then back again Pin
Paul Selormey16-Feb-03 19:26
Paul Selormey16-Feb-03 19:26 
GeneralRe: Need help with casting __gc-pointer to void* and then back again Pin
ThatsJustMe17-Feb-03 3:20
ThatsJustMe17-Feb-03 3:20 
GeneralRe: Need help with casting __gc-pointer to void* and then back again Pin
Paul Selormey17-Feb-03 13:13
Paul Selormey17-Feb-03 13:13 
QuestionCompiling .cpp in .net dev studio ? Pin
monkh12-Feb-03 11:59
monkh12-Feb-03 11:59 
AnswerRe: Compiling .cpp in .net dev studio ? Pin
Paul Selormey16-Feb-03 19:40
Paul Selormey16-Feb-03 19:40 
Generalstatic constant string Pin
VizOne12-Feb-03 2:24
VizOne12-Feb-03 2:24 
Hi there!

I have just started using managed c++ (until now I have always used "pure" C++), so I have a question that might sound stupid to you.

I want my class to have a string-member that descibes the class. This string is for example returned by ToString(). As a C++ I would want to make it static const to ensure it is only once in memory and cannot be altered. However, ToString() returns a non-const String. Do I have to copy the string all the time I call ToString()?

Maybe some code shows what I mean:

<br />
public __gc class Foo<br />
{<br />
public:<br />
   System::String * ToString();<br />
private:<br />
   static const System::String * ClassID = S"This is class Foo";<br />
};<br />
<br />
System::String * Foo::ToString()<br />
{<br />
    //This won't work because return value is non-const<br />
    //return Foo::ClassID;<br />
<br />
    //This won't work either, as callee might manipulate string<br />
    // return const_cast<System::String*>(Foo::ClassID);<br />
<br />
    // The only possibility?<br />
   return static_cast<System::String*>(const_cast<System::String*>(Foo::ClassID)->Clone());<br />
}<br />



Are there any other ways to avoid copying all the time?

Greetings

Andre (VizOne) Loker
GeneralRe: static constant string Pin
VizOne13-Feb-03 8:33
VizOne13-Feb-03 8:33 
GeneralentryPoint of a PE file Pin
blacksun_damn4-Feb-03 19:44
blacksun_damn4-Feb-03 19:44 
GeneralConverting byte[] to System::Byte[] and vice versa Pin
Martin Haesemeyer2-Feb-03 7:45
Martin Haesemeyer2-Feb-03 7:45 
GeneralRe: Converting byte[] to System::Byte[] and vice versa Pin
Paul Selormey2-Feb-03 19:21
Paul Selormey2-Feb-03 19:21 
GeneralRe: Converting byte[] to System::Byte[] and vice versa Pin
Martin Haesemeyer3-Feb-03 4:33
Martin Haesemeyer3-Feb-03 4:33 
GeneralRe: Converting byte[] to System::Byte[] and vice versa Pin
Paul Selormey3-Feb-03 13:29
Paul Selormey3-Feb-03 13:29 
GeneralOptimizing Event Implementation in MC++ Pin
Paul Selormey30-Jan-03 14:59
Paul Selormey30-Jan-03 14:59 
GeneralRe: Optimizing Event Implementation in MC++ Pin
Jeff J31-Jan-03 12:00
Jeff J31-Jan-03 12:00 
GeneralRe: Optimizing Event Implementation in MC++ Pin
Paul Selormey31-Jan-03 23:59
Paul Selormey31-Jan-03 23:59 
GeneralSerial Communication threw .NET C++ Pin
megadith28-Jan-03 3:50
megadith28-Jan-03 3:50 
QuestionHow to call the ::MessageBox ? Pin
roy_a24-Jan-03 23:13
roy_a24-Jan-03 23:13 
AnswerRe: How to call the ::MessageBox ? Pin
Jeff J25-Jan-03 10:29
Jeff J25-Jan-03 10:29 
GeneralManaged C++ to PDA Pin
pjm31323-Jan-03 6:30
pjm31323-Jan-03 6:30 
GeneralRe: Managed C++ to PDA Pin
Jeff J25-Jan-03 10:08
Jeff J25-Jan-03 10:08 
Generalvisual designing of the forms Pin
suka23-Jan-03 5:19
suka23-Jan-03 5:19 
GeneralRe: visual designing of the forms Pin
Jeff J25-Jan-03 9:55
Jeff J25-Jan-03 9:55 
GeneralCrystal Report Pin
Exceter20-Jan-03 18:58
Exceter20-Jan-03 18:58 

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.