使用ref类来保存数据? [英] Using a ref class to hold data ?

查看:154
本文介绍了使用ref类来保存数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ref类来保存托管C ++ DLL中的数据。



类型(Stuff :: Manager)来自第三方.NET DLL。



问题在代码块的注释中。



I have a ref class to hold data in a Managed C++ DLL.

The type (Stuff::Manager) is from a 3rd party .NET DLL.

Question is in the comment in the code block.

ref class MyDataClass
{
public: 
  static Stuff::Manager^ m_Manager;
/// ...
}





伪代码...





With pseudo-code ...

void f()
{
  Stuff::Manager^ manager = GetManager();
  MyDataClass::m_Manager = manager; // Is this a transfer of ownership or just a copy ? or will manager be destroy by the scope ?
}

void g()
{
  MyDataClass::m_Manager->DoSomething();
}

int Main()
{
  f();
  g();
}





谢谢。



什么我试过了:



我不确定我需要尝试或谷歌找到它。



Thanks.

What I have tried:

I am not certain what I need to try or google to find that out.

推荐答案

manager是一个指针,因为它是托管的.NET代码,你不必担心处理它。

它将自动完成。
manager is a pointer and since it's managed .NET code you don't have to worry about disposing it.
It will be done automatically.


这篇关于使用ref类来保存数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆