Click here to Skip to main content
16,005,491 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionCommercial vendor hacking your code? Pin
fredsparkle19-Aug-08 9:25
fredsparkle19-Aug-08 9:25 
AnswerRe: Commercial vendor hacking your code? Pin
Paul Conrad22-Aug-08 18:13
professionalPaul Conrad22-Aug-08 18:13 
QuestionOpening External Programs Pin
C# Beginner Nick18-Aug-08 13:52
C# Beginner Nick18-Aug-08 13:52 
AnswerRe: Opening External Programs Pin
Perspx18-Aug-08 14:05
Perspx18-Aug-08 14:05 
AnswerRe: Opening External Programs Pin
teejayem18-Aug-08 14:17
teejayem18-Aug-08 14:17 
AnswerRe: Opening External Programs Pin
Mark Salsbery18-Aug-08 14:40
Mark Salsbery18-Aug-08 14:40 
QuestionManged pointer to local object Pin
LionAM16-Aug-08 22:39
LionAM16-Aug-08 22:39 
AnswerRe: Manged pointer to local object [modified] Pin
Mark Salsbery18-Aug-08 8:47
Mark Salsbery18-Aug-08 8:47 
LionAM wrote:
is there any other way to find out if the object
pointed to by pt was destroyed?


pt is still valid in your code.

There's no "pointers" here - these are managed references.
You have created a new reference to t by assigning a tracking
reference of t to pt. As long as pt stays in scope it is a
valid Test reference.


You can assign nullptr to references...
Test^ pt;
{
   Test t;
   pt = %t;
}
pt = nullptr;
if (nullptr != pt)
{
   pt->...
}


*edit*  I played around with this and with stack based semantics<br />
the destructor is still called as you stated.  This behavior makes code <br />
like your example dangerous.<br />
<br />
I'd prefer using all reference semantics if I was going to obtain additional<br />
references, something like

Test^ pt;
{
   Test ^t = gcnew Test();
   pt = t;
}
delete pt; // destructor called here!
pt = nullptr;

That seems clearer to me *shrug*


Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

modified on Monday, August 18, 2008 3:17 PM

GeneralRe: Manged pointer to local object Pin
LionAM19-Aug-08 4:35
LionAM19-Aug-08 4:35 
GeneralRe: Manged pointer to local object Pin
Mark Salsbery19-Aug-08 6:13
Mark Salsbery19-Aug-08 6:13 
QuestionBook for learning Graphics prgrming ... Pin
micro_prgmr13-Aug-08 21:11
micro_prgmr13-Aug-08 21:11 
QuestionLots of data Pin
ericksonbrian12-Aug-08 8:32
ericksonbrian12-Aug-08 8:32 
GeneralRe: Lots of data [modified] Pin
dybs13-Aug-08 17:28
dybs13-Aug-08 17:28 
QuestionCombine WinForm and DirectDraw Pin
ArneKruger9-Aug-08 21:28
ArneKruger9-Aug-08 21:28 
Question.NET Flow Diagrams Pin
dybs8-Aug-08 15:31
dybs8-Aug-08 15:31 
QuestionCOM Exception when trying to create new com object Pin
Sara1237-Aug-08 0:11
Sara1237-Aug-08 0:11 
GeneralRe: COM Exception when trying to create new com object Pin
Perspx7-Aug-08 0:46
Perspx7-Aug-08 0:46 
QuestionAmcap SDK Pin
suefyzah6-Aug-08 21:21
suefyzah6-Aug-08 21:21 
AnswerRe: Amcap SDK Pin
Mark Salsbery7-Aug-08 7:41
Mark Salsbery7-Aug-08 7:41 
QuestionHow can I specify a different application icon based on different configuration Pin
travismonkey@gmail.com6-Aug-08 10:48
travismonkey@gmail.com6-Aug-08 10:48 
Question[Message Deleted] Pin
Behzad Seyfi5-Aug-08 20:29
Behzad Seyfi5-Aug-08 20:29 
AnswerRe: How can I use Canvas Control in C++/CLI? Pin
Mark Salsbery6-Aug-08 5:47
Mark Salsbery6-Aug-08 5:47 
GeneralRe: How can I use Canvas Control in C++/CLI? Pin
led mike6-Aug-08 6:07
led mike6-Aug-08 6:07 
GeneralRe: How can I use Canvas Control in C++/CLI? Pin
Mark Salsbery6-Aug-08 6:31
Mark Salsbery6-Aug-08 6:31 
GeneralRe: How can I use Canvas Control in C++/CLI? Pin
led mike6-Aug-08 7:07
led mike6-Aug-08 7:07 

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.