开发者

Store and retrieve native pointer from System::Object^

I want to store a pointer to a native class in System::Object^ and retrieve it back.

class ABC;

ABC * d = new ABC();

System::Object^ Tag;
Tag = d; //This throws an error

//in a different function

ABC * c = safe_cast<ABC*>Tag; // this throws an error.

Wh开发者_如何学JAVAich is the proper way to achieve the above behavior?


Use IntPtr structure instead of Object.

IntPtr Tag(d);

ABC * c = (ABC*)Tag.ToPointer();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜