首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

C++/CLI 内 delete 释放内存的有关问题

2012-03-22 
C++/CLI 内 delete 释放内存的问题.C/C++ codeusing namespace Systempublic ref struct APP{String^ The

C++/CLI 内 delete 释放内存的问题.

C/C++ code
using namespace System;public ref struct APP{    String^ TheString;    APP(String^ inString)    {        TheString = inString;    }};public ref class BPP{public: property APP^ TheAPP;public:    BPP(APP^ inAPP)    {        TheAPP = inAPP;    }};public ref class CPP{public: property APP^ TheAPP;public:    CPP(APP^ inAPP)    {        TheAPP = inAPP;    }};int main(){    APP^ app = gcnew APP("Weird.");    CPP^ cpp = gcnew CPP(app);    delete cpp;    Console::WriteLine(cpp->TheAPP->TheString);    Console::Read();    return 0;}

这代码编译通过, 运行起来输出为: Weird.
很费解, 求解释.

[解决办法]
托管内存你是直接管不了的

[解决办法]
dispose是释放非托管

热点排行